home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / Docs / ace.fmt < prev    next >
Text File  |  1996-09-12  |  111KB  |  2,992 lines

  1.  
  2.                 +----------+
  3.                 | ACE v2.4 |
  4.                 +----------+
  5.  
  6.  
  7.       CONTENTS                       LINE  PAGE
  8.       --------                        ----  ----
  9.  
  10.   (i)   Introduction
  11.  
  12.     Printing this document......................%%
  13.     What is ACE?................................%%
  14.     Who is it for?..............................%%
  15.  
  16.     ------------------------------------------------
  17.  
  18.  (ii)    Getting started
  19.  
  20.     Installation................................%%
  21.     Using the compiler..........................%%
  22.     Compiler options............................%%
  23.     Running ACE programs........................%%
  24.     About the example programs..................%%
  25.  
  26.     ------------------------------------------------
  27.  
  28.  (iii)  A hitch-hiker's guide to ACE 
  29.  
  30.     General comments............................%%
  31.  
  32.     The preprocessor and #include files.........%%
  33.  
  34.     Data types, expressions, constants..........%%
  35.     Precedence of operators.....................%%
  36.     Indirection operators.......................%%
  37.     Identifiers.................................%%
  38.  
  39.     Sequential Files............................%%
  40.     Random Files................................%%
  41.  
  42.     Command line and Workbench arguments........%%
  43.  
  44.     Subprograms.................................%%
  45.     Structures..................................%%
  46.     Shared library function calls...............%%
  47.     Machine code calls..........................%%
  48.  
  49.     External references.........................%%
  50.     Common and Global variables.................%%
  51.     Subprogram modules (SUBmods)................%%
  52.         
  53.     Windows.....................................%%
  54.     Screens.....................................%%
  55.  
  56.     Gadgets.....................................%%
  57.     Menus.......................................%%
  58.     Requesters..................................%%
  59.  
  60.     Turtle Graphics.............................%%
  61.     Loading & displaying IFF pictures...........%%
  62.  
  63.     Sound.......................................%%
  64.  
  65.     Event trapping..............................%%
  66.  
  67.     Interprocess Communication..................%%
  68.  
  69.     Error handling..............................%%
  70.  
  71.     Notes for assembly programmers..............%%
  72.  
  73.     Limitations.................................%%
  74.     Known bugs..................................%%
  75.  
  76.     ------------------------------------------------
  77.  
  78. (iv)    Stop bits
  79.  
  80.     Future versions.............................%%
  81.  
  82.     A note to PD libraries and reviewers........%%
  83.  
  84.     Disclaimer..................................%%
  85.  
  86.     References..................................%%
  87.  
  88.     Contacting the author.......................%%
  89.  
  90.     CyberspACE: FTP, WWW, mailing list..........%%
  91.  
  92.     Final word..................................%%
  93.  
  94.         ================================================
  95.  
  96.  
  97. $$Printing this document
  98. ----------------------
  99. The simplest way to print this document is to use the pager utility which
  100. can be found in the utils/pager directory of the ACE distribution. Before
  101. printing, be sure to set your printer preferences such that the left and 
  102. right margin settings are 0 and 80 respectively.
  103.  
  104.  
  105. $$What is ACE?
  106. ------------
  107.  AmigaBASIC Compiler with Extras?
  108.  A Creative Environment? 
  109.  A Compiler for Everyone?
  110.  A Cool Enterprise?
  111.  Automatic Computing Engine (ala Alan Turing)?
  112.  Dr Who's last companion?  
  113.  
  114. Okay, seriously...
  115.  
  116. ACE is a freely distributable, recursive descent, peephole-optimising Amiga 
  117. BASIC compiler which produces A68K-compatible assembly source code. ACE runs 
  118. under Wb 1.3, 2.x and up, as do the executables it produces. ACE will run in 
  119. 512K, but more than this is required for programs beyond about 250 lines.
  120.  
  121. ACE supports a large subset of AmigaBASIC. It also provides a variety of 
  122. commands, functions and features not found in AmigaBASIC.
  123.  
  124. In many cases, ACE programs produce results which are similar or identical 
  125. to programs written in AmigaBASIC.
  126.  
  127. Any differences between the two are discussed in this document and the command 
  128. and function reference (ref.doc).
  129.  
  130. The following files constitute a complete ACE package:
  131.  
  132.         executables
  133.         -----------      
  134.     bas        - A shell script which automates
  135.                 the production of ACE executables
  136.               (1.3 and 2.x/3.x versions).
  137.     app        - A simple preprocessor.
  138.     ace        - The BASIC compiler.
  139.     a68k        - Charlie Gibbs' 68000 assembler.
  140.     blink        - The Software Distillery's linker.
  141.     muchmore    - The file viewer by Fridtjof Siebert & 
  142.               Christian Stiens (1.3 and 2.x/3.x versions).
  143.  
  144.      documents
  145.     ---------        
  146.     ace.doc/guide    - The document you are reading, which describes ACE.
  147.     ref.doc/guide     - A command and function reference for ACE.
  148.     example.guide    - Examples of ACE command and function usage.
  149.     history        - A history of ACE's development.
  150.     a68k.doc    - Documentation for the assembler.
  151.     blink.doc    - Documentation for the linker.
  152.  
  153.     scanned libraries (NOT shared libraries)
  154.     -----------------
  155.     ami.lib        - A freely distributable version of amiga.lib.
  156.     startup.lib    - A library of routines needed at the start and
  157.               end of an ACE program run.
  158.     db.lib        - A library of assorted routines used by ACE
  159.               programs.
  160.  
  161.     other stuff
  162.     -----------
  163.     includes    - Some useful ACE include files. 
  164.     icons        - ACE tool and document icons.
  165.     utils        - Miscellaneous utilities.
  166.     examples    - Example programs which demonstrate many of 
  167.               ACE's capabilities.
  168.      AIDE        - A graphical front-end for ACE.
  169.  
  170. With one exception (see the discussion of file requesters under Wb 1.3 in 
  171. the "Requesters" section) ACE programs do not require any special run-time 
  172. shared libraries, so the executables which the compiler produces (via the 
  173. assembler and linker) are completely portable, requiring only the standard 
  174. Amiga shared libraries in your LIBS: directory. The three ".lib" files 
  175. mentioned above are scanned libraries and code from these is included at 
  176. link time.
  177.  
  178. ACE is written in C (Sozobon's ZC v1.01), while db.lib and startup.lib are 
  179. written in assembler (~50%) and C. I may eventually switch to SAS C.
  180.  
  181. A68K and Blink are used to assemble and link the code produced by ACE.
  182.  
  183. The MicroEmacs (v1.3 & v2.1) editor has been used throughout every stage 
  184. of ACE's development. It works for me.
  185.  
  186. The complete ACE package may be freely distributed.
  187.  
  188.  
  189. $$Who is it for?
  190. --------------
  191. ACE is intended for anyone who already knows BASIC and wants one or more 
  192. of the following:
  193.  
  194.     - Faster program execution.
  195.  
  196.     - Independence from the BASIC interpreter, ie: standalone 
  197.       programs which are runnable from the CLI/Shell and Workbench.
  198.  
  199.     - Extra commands, functions and features: turtle graphics,
  200.       command-line (and Workbench) arguments, recursion, SUBs with 
  201.       return values, external references, named constants, structures, 
  202.       include files, better WAVE command, gadgets, requesters, ability
  203.       to create subprogram libraries, interprocess communication, etc.
  204.  
  205. Maybe you don't wish to learn another high-level language, or perhaps you 
  206. already use C or assembler but prefer to use BASIC for some tasks while 
  207. still having the power of a compiled language.
  208.  
  209. ACE is a general purpose language so in theory at least, it can be applied
  210. to any programming task you like. In practice however, I find ACE to be
  211. most useful for writing small to medium sized programs where speed is 
  212. important but so is ease of programming.
  213.  
  214. ACE is also a useful prototyping language. It allows you to get something 
  215. up and running quickly to test an idea. You may later decide to re-code in 
  216. C or assembler, or you may just add some polish to the existing ACE program.
  217.  
  218. The latter is becoming more feasible as ACE matures.
  219.  
  220. Here are some programs that have been written with ACE:
  221.  
  222.     - Shell utilities, eg: basic calculator (see ACE:prgs/ShellUtils).
  223.     - An 8SVX sound sample player.
  224.     - Fractal graphics programs.
  225.     - Neural networks.
  226.     - Astronomy programs, eg: galaxy collision simulator,
  227.       Jovian satellite position predictor, Messier object database.
  228.     - An Integrated Development Environment: AIDE.
  229.     - A GUI designer which generates ACE code: ReqEd.    
  230.     - A home security/wakeup system.
  231.     - A program which matches section headings to line and page 
  232.       numbers to create the document you are now reading from an
  233.       unformatted version of it.
  234.     - Workbench calculators (Me, John Stiwinter).
  235.     - A SpiroGraph simulator (Chuck Kenney).
  236.     - A serial Stratego game (Dan Oberlin).
  237.     - A control program for a 16" reflecting telescope (Neil Sproston).
  238.     - An assembly code optimiser for ACE programs (Manuel Andre).
  239.     - Interpreters for simple dialects of BASIC and Lisp.
  240.     - A variety of communications (simple terminal, X10) programs.
  241.     - A MED module player (Lauri Lehmus).
  242.     - A Protracker module player (John Mason).
  243.     - A preprocessor for ACE source code (Daniel Seifert).
  244.  
  245.  
  246. $$Installation
  247. ------------
  248. Installing ACE consists of:
  249.  
  250.     - Unpacking the archive.
  251.  
  252.     - Adding a few commands to your s:user-startup (Wb 2.x/3.x) or 
  253.       s:startup-sequence (Wb 1.3) file.
  254.  
  255. First create a new drawer (eg. ACE) on your hard disk, open a shell window, 
  256. change to the new directory, and unpack the archive into it with:
  257.  
  258.     lha -a x <archive-name>
  259.  
  260. eg.    lha -a x ace24.lha
  261.     
  262. The "-a" switch preserves file attributes (eg. the "s" bit on shell scripts) 
  263. in the archive.
  264.  
  265. As you can see, it is *assumed* that you have a hard disk. If you don't, 
  266. unpack the ACE archive into the RAM disk and place the contents of the 
  267. distribution onto more than one floppy disk from there.
  268.  
  269. Next, add the following lines to your user-startup or startup-sequence 
  270. script:
  271.  
  272.     assign ACE: <volume or directory>
  273.     path ACE:bin add
  274.  
  275. where <volume or directory> is the name of the disk or directory where
  276. the main ACE files now reside (eg: assign ACE: sys:ACE).
  277.  
  278. In addition, you need to add three more statements to your startup-sequence
  279. or user-startup script:
  280.  
  281.     assign ACElib:       ACE:lib     ; bas finds scanned libraries here.
  282.     assign ACEbmaps:   ACE:bmaps     ; ace looks here for .bmap files.
  283.     assign ACEinclude: ACE:include     ; app uses this for include files.
  284.  
  285. Now reboot your Amiga to let the above path and assign commands take effect.
  286.  
  287. That's it!
  288.  
  289.  
  290. $$Using the compiler
  291. ------------------
  292. Starting with ACE v2.0 there are two ways to use the compiler:
  293.  
  294.     - From the shell/CLI.
  295.     - Via an Integrated Development Environment: AIDE.
  296.  
  297. Whichever environment you choose to work with ACE in, read on.
  298.  
  299. ACE expects all BASIC source files to have a ".b" or ".bas" extension.
  300.  
  301. If you have a program called foo.b[as], you would invoke the compiler thus:
  302.  
  303.     ace foo    (or ace foo.b[as])
  304.  
  305. This would produce foo.s, an A68K-compatible assembly source (text) file.
  306.  
  307. If you wanted to preprocess, compile, assemble and link foo.b[as], you'd 
  308. type:
  309.  
  310.     bas foo
  311.  
  312. which would yield foo (the executable).
  313.  
  314. The bas script sets the stack to 40000 bytes. Before running ACE by itself,
  315. you will need to set this. A minimum stack size seems to be around 5000
  316. for many ACE compilations, but I recommend 40000 to be safe.
  317.  
  318. If your Amiga GURUs or hangs during a compile or produces garbage in the 
  319. shell, you can be confident that the stack is too small.
  320.  
  321. You can either create a BASIC source file using an editor or in the AmigaBASIC 
  322. environment. If you want to compile a program developed with the interpreter,
  323. just save the program in ASCII format thus:
  324.  
  325.     save "foo.b[as]",a
  326.  
  327. ACE will only compile ASCII source files, not AmigaBASIC's compressed format.
  328.  
  329. For those who don't have access to the AmigaBASIC interpreter but who wish
  330. to convert old AmigaBASIC programs not saved in ASCII format, see the 
  331. ACE:utils directory for a utility called ab2ascii written by Stefan Reisner.
  332.  
  333.  
  334. $$Compiler options
  335. ----------------
  336. The full command line syntax for ACE is:
  337.  
  338.     ace [words | -bcEilmOw] <sourcefile>[.b[as]]
  339.  
  340. which indicates that there are currently eight optional compiler switches. 
  341.  
  342. Before giving a description of these switches however, let me say something
  343. about the optional "words" parameter. If the command:
  344.  
  345.     ace words
  346.  
  347. is given, all the reserved words which are known to the compiler will be
  348. dumped to standard output (ie. to the shell/CLI). Using redirection thus:
  349.  
  350.     ace words > rwords
  351.  
  352. will result in a file containing this information. This feature will be
  353. useful for anyone wanting to know which words are reserved by the compiler. 
  354. AmigaBASIC and ACE keywords are differentiated.
  355.  
  356. The switches can appear in any combination (eg: -bO, -clb, -O, -ObE) but 
  357. they *are* case sensitive (so -b does not equal -B).
  358.  
  359. The "b" switch tells the compiler to include code to check for ctrl-c breaks 
  360. by the user. The inclusion of this code can result in noticeably larger
  361. assembly source files, but execution speed doesn't seem to suffer appreciably.
  362. When a ctrl-c is detected, the program will clean up and exit but user-defined
  363. windows and screens will remain open. The use of ON BREAK can get around this 
  364. by allowing for user-controlled clean up (see the "Event Trapping" section
  365. below). See also the "w" switch.
  366.  
  367. The "c" switch includes each line of ACE source code as a comment in the
  368. final assembly source file. This was requested as a debugging aid. Warning:
  369. the presence of such comments interferes with peephole optimisation. Also be
  370. aware that ACE sometimes includes extra code apart from that which you might
  371. expect purely on the basis of the source code.
  372.  
  373. The "E" switch creates a file in the current directory called ace.err which
  374. contains all error messages generated during a compliation. Error messages
  375. are still displayed to the screen during compilation however.
  376.  
  377. The "i" switch tells ACE to make an icon for the executable resulting from 
  378. the compilation. The file "ACE:icons/exe.info" must exist as it is used as
  379. the source file for the icon. This allows you to use an icon of your own if
  380. you so wish.
  381.  
  382. The "l" switch causes the compiler to display each line of ACE source code 
  383. as it is being compiled.
  384.  
  385. The "m" switch creates a linkable module containing no startup code (See
  386. "Creating & using ACE subprogram modules" section below).
  387.  
  388. The "O" switch causes the assembly source code produced by ACE to be optimised.
  389. A range of peephole optimisations is currently carried out. Assembly code size
  390. reductions of around 5% to 10% are usual. Speed improvements vary, depending
  391. upon the program, however I recommend the use of the -O switch for all programs
  392. where speed is the least bit important. ACE's optimiser has been improved since 
  393. v2.0 and it will continue to be improved.
  394.  
  395. The "w" switch tells ACE to include checks for window close-gadget clicks.
  396. ACE checks all open windows and upon detecting a close-gadget click, the
  397. clicked window is closed and the program exits. However, any other open
  398. windows or screens will not be closed. The use of ON WINDOW can get around 
  399. this by allowing for a user-defined clean-up subroutine (see the "Event 
  400. Trapping" section below).
  401.  
  402. See also the OPTION command in ref.doc.
  403.  
  404. The syntax for the bas script is:
  405.  
  406.     bas [-bcEilmOw] <sourcefile> [<objectfile>]
  407.  
  408. where <sourcefile> is the program to be compiled (without the .b[as] 
  409. extension) and <objectfile> is a C, assembly or ACE module which has been 
  410. (compiled and) assembled to produce an object file.
  411.  
  412. The <objectfile> is linked with the output of ACE+A68K along with db.lib, 
  413. startup.lib and ami.lib. This is necessary when an external function or 
  414. variable in <objectfile> is referenced by an ACE program. For more about 
  415. external functions, see the sections "External references" and "Creating & 
  416. using ACE subprogram modules" below.
  417.  
  418.  
  419. $$Running ACE programs
  420. --------------------
  421. ACE programs can be run from either a shell/CLI or Workbench. In the latter
  422. case a tool icon must be created for the executable. One has been provided
  423. with the archive in the icons directory (exe.info). Refer to the "i" switch 
  424. in "Compiler options" above re: automatic icon creation by the compiler.
  425.  
  426.  
  427. $$About the example programs
  428. --------------------------
  429. I have written a number of programs which illustrate most of the features
  430. of ACE up to this point and you should find these with the distribution.
  431.  
  432. Several programs are related to chaos theory and fractals. The remainder 
  433. are an assorted bunch which demonstrate ACE's capabilities.
  434.  
  435. The information for the chaos/fractal programs came from a wide variety of 
  436. sources. The algorithms for henon.b and lorenz.b came from "Dynamical systems 
  437. and fractals: computer graphics experiments in Pascal" by Becker & Dorfler, 
  438. 1990.
  439.  
  440. Some programs are optimised at the source level and some are not. You'll 
  441. find that using integer variables can often result in quite dramatic 
  442. improvements in program execution speed (eg: try replacing op% with op! and 
  443. k% with k! in ifs.b and you'll see what I mean).
  444.  
  445. There are several examples which demonstrate the use of recursive 
  446. subprograms in ACE (eg: misc/fact.b).
  447.  
  448. Another area of interest for me is neural networks and you'll find a 
  449. program called gfx/hopnet.b, which shows graphically how a simple Hopfield 
  450. network changes under various conditions.
  451.  
  452. Other programs include a talking clock (tclock.b), a sound sample player 
  453. (sound/play.b) and a command-line calculator (ShellUtils/bc.b).
  454.  
  455.  
  456. $$General comments
  457. ----------------
  458. I made a decision very early on in the project to allow standard I/O (for 
  459. shell/CLI). All other windows are (as of ACE v2.0) Intuition windows.
  460.  
  461. The execution speed of most programs (especially with graphics, eg: ifs.b)
  462. is, as you might expect, *fast* compared to interpreted AmigaBASIC.
  463.   
  464. No error messages are given at run-time (but some errors are reported via ERR
  465. and ON ERROR), nor is there any stack overflow or array bounds checking. 
  466.  
  467. Labels are supported and can be used with GOSUB and GOTO. Line numbers are 
  468. supported, but are only necessary for old BASIC programs. Also, ACE's rich 
  469. assortment of control constructs makes the use of GOTO largely redundant.
  470.  
  471. Available control constructs are: WHILE..WEND, REPEAT..UNTIL, IF..THEN..ELSE,
  472. IF..THEN..ELSE..END IF, CASE..END CASE, ON..GOTO, ON..GOSUB, SUB..END SUB and 
  473. GOSUB..RETURN.
  474.  
  475. Apart from single line comments with REM and ' ACE allows block comments with
  476. { and }. For example:
  477.  
  478.  { comments can span more than 
  479.    one line like this }
  480.  
  481. Multi-statements are also supported by ACE - as they are in AmigaBASIC, eg:
  482.  
  483.  x$="hello":y$="there":say translate$(x$+" "+y$)
  484.  
  485. In ACE (as in AmigaBASIC) end-of-line characters (ASCII 10) are significant,
  486. so a line continuation character (~) must be used to extend expressions and
  487. parameter lists (etc) over more than one line, eg.
  488.  
  489.  DECLARE FUNCTION MyAmazingExternalFunction(theFirst, theSecond, theThird, ~
  490.                         theFourth) EXTERNAL
  491.  
  492. Note that this feature is ACE-specific. Multi-statements may be split across
  493. lines in similar fashion, eg.
  494.  
  495.     CASE
  496.       n = 1 : print "This is the one!" :~
  497.           ++n :~
  498.           print "That will do."
  499.       .
  500.       .
  501.       .
  502.     END CASE
  503.  
  504. On a related note, statement blocks are also supported via BLOCK..END BLOCK.
  505.  
  506.  
  507. $$The preprocessor and #include files
  508. ------------------------------------
  509. The ACE preprocessor: APP, is modest when compared to the C preprocessor,
  510. but is not the only choice available to the ACE programmer (see the note 
  511. at the end of this section).
  512.  
  513. Its main function thus far is for the inclusion of files with the #include 
  514. directive. As in C, #include "filename" looks for the file as specified, 
  515. while #include <filename> looks for the file in a local include directory 
  516. (see "Installation"). A file will only ever be included once.
  517.  
  518. The #include directive can also be used in included files, but since file 
  519. inclusion is recursive, watch your stack size (40000 bytes is plenty).
  520.  
  521. APP also handles single-line comments (text following a "'") and block
  522. comments (starting with "{" and ending with "}"). This is partly to allow
  523. #include commands to be commented out and also to make less work for the 
  524. compiler. However, the compiler does still handle comments in case the pre-
  525. processor isn't invoked. APP does not handle REM since this is a BASIC 
  526. statement.
  527.  
  528. The syntax for APP is: 
  529.  
  530.     app <source> <dest> 
  531.  
  532. The bas script uses APP by first preprocessing an ACE source file to the
  533. RAM:T directory.
  534.  
  535. Use of #include has the effect of adding lines to the preprocessed ACE 
  536. source, which has an impact upon the physical location of lines from the
  537. main ACE file when transfered to the destination file.
  538.  
  539. ACE include files have two purposes. As in C they can be used to include
  540. constants and structure definitions. Second, as with files like WBarg.h,
  541. ACE include files may contain subprogram definitions and although this is 
  542. quite possible in C, it seems to be less often done under the guise of .h 
  543. files. I have arbitrarily chosen to append all include files with .h but 
  544. there is no reason why this need be so. Purists will probably be aghast.
  545.  
  546. APP will be improved as time goes by.
  547.  
  548. Note that if you wish to use the new ACE include files (created by Nils
  549. Sjoholm), you will need to use an actual C preprocessor instead of APP,
  550. and one has been provided (acpp), along with alternate bas scripts (see
  551. bas2 and bas3) for exactly this purpose.
  552.  
  553. NOTE: For compiling programs which use the new include files in 
  554.       ACEinclude: you should use a better preprocessor, eg. ACPP or NAP.
  555.       Be aware however that ACPP assumes that ACEinclude: = ACE:include.
  556.   
  557.  
  558. $$Data types, expressions and constants
  559. ------------------------------------- 
  560. The following fundamental data types are currently supported:
  561.  
  562.     - signed short integers (2 bytes = 16 bits)
  563.     - signed long integers  (4 bytes = 32 bits)
  564.     - single-precision: Motorola fast floating point (4 bytes = 32 bits)
  565.     - strings (default length of 1024 bytes including ASCII 0 at end of string) 
  566.  
  567. Exponential and fixed-point formats are recognised by ACE for single-precision 
  568. numbers.
  569.  
  570. Expression parsing is the same as for AmigaBASIC, as is the precedence of 
  571. operators. Evaluation of _all_ expressions proceeds from left to right.
  572. This includes exponentiation, so 2^3^2 will be evaluated as (2^3)^2.
  573.  
  574. In addition, due to the higher precedence of exponentiation over unary 
  575. negation and the way ACE's recursive descent parser works, 4^(-2) is okay, 
  576. but 4^-2 isn't.
  577.  
  578. ACE supports full 32-bit and single-precision floating point math:
  579.  
  580.     addition, subtraction, multiplication:
  581.         
  582.         - 16-bit integer
  583.         - 32-bit integer
  584.         - single-precision 
  585.  
  586.     division & modulo arithmetic:
  587.  
  588.         - 32-bit integer
  589.         - single-precision
  590.  
  591. Increment and decrement operators are provided in ACE in the following form:
  592.  
  593.     ++<variable> OR --<variable>
  594.  
  595. The value of the simple, external, global, or common variable is incremented 
  596. or decremented by 1.
  597.  
  598. Notice that ++ and -- are pre-increment & pre-decrement operators ONLY (ie.
  599. not also post-increment/decrement). Those familiar with C will recognise 
  600. these operators and their utility. In terms of efficiency: ++x is better 
  601. than x=x+1.  
  602.                     
  603. Unlike interpreted AmigaBASIC, hexadecimal and octal constants can be either 
  604. short or long values. This makes for nicer addressing with PEEK & POKE. Also,
  605. the prefixes &H and &O may precede an integer anywhere that it makes sense,
  606. including in strings submitted to the VAL function. The effect of &H and &O
  607. is to indicate that a hexadecimal or octal value follows. The use of these 
  608. prefixes is consistent with AmigaBASIC.
  609.  
  610. Trailing characters (%&!#) after constants cause coercion from one numeric
  611. data type to another, as in AmigaBASIC, eg:
  612.     
  613.     Delay(50&)   '..50 is coerced from short to long integer
  614.     x=12.5*65!   '..65 is coerced from short integer to single-precision
  615.  
  616. Using these type-qualifier characters means that ACE doesn't have to generate
  617. numeric conversion code. This leads to smaller assembly code source files.
  618.  
  619. As in AmigaBASIC expression evaluation, all operands in an expression are 
  620. converted to the data type of the most precise operand. Logical operators 
  621. (AND,EQV,IMP,NOT,OR,XOR) convert their operands to integer values as does 
  622. the integer division operator "\". Relational operators (= <> > < >= <=) 
  623. yield long integer results.  
  624.   
  625. ACE's boolean values are as follows: 0=false, N=true where N is any 
  626. non-zero long integer. Note that relational operations give -1 for true 
  627. (since: NOT -1 = 0).
  628.  
  629. Please note that in addition to their use in relational expressions, the 
  630. logical operators (AND, NOT...) actually work in bitwise fashion. This means 
  631. that you can create bitwise AND masks and perform other operations on groups 
  632. of bits, as desired. The SHL and SHR functions may also prove useful in this 
  633. respect (see ref.doc).
  634.  
  635. ACE allows you to define named global signed numeric constants with the 
  636. CONST directive (see command and function reference).
  637.  
  638. Strings have a default length of 1K instead of the usual 32K, since ACE 
  639. programs reserve memory for each string immediately at run-time which could
  640. result in quite memory hungry executables if strings were too large. It is 
  641. possible however, to define strings which are longer or shorter than 1K (see 
  642. the STRING command).
  643.  
  644. ACE strings are NULL terminated, ie: the last character is an ASCII 0, as in
  645. strings manipulated by C's standard library functions.
  646.  
  647. A string literal without a final '"' will be truncated at the end of the 
  648. line.
  649.  
  650.  
  651. $$Precedence of operators
  652. -----------------------
  653. ACE follows AmigaBASIC in operator precedence, with the addition of structure 
  654. dereferencing and indirection operators.
  655.  
  656.     Level    Operation/Operator                Symbol
  657.     -----    ------------------                ------
  658.  
  659.     1.      Structure Member Dereferencing,            ->
  660.             Parentheses and Address Operator        () @
  661.     2.      Indirection Operators                *% *& *!    
  662.     3.      Exponentiation                    ^
  663.     4.      Unary Negation                    -
  664.     5.      Multiplication and Floating-Point Division    * /
  665.     6.      Integer Division                \
  666.     7.      Modulo Arithmetic                MOD
  667.     8.      Addition and Subtraction            + -
  668.     9.      Relational Operators                = < > <= >= <>
  669.     10.     NOT
  670.     11.     AND
  671.     12.     OR and XOR
  672.     13.     EQV
  673.     14.     IMP
  674.  
  675. The use of parentheses in an expression forces the enclosed term to be 
  676. evaluated before adjacent terms. Expression evaluation always proceeds 
  677. from left to right in ACE and AmigaBASIC.
  678.  
  679.   
  680. $$Indirection operators
  681. ---------------------
  682. ACE has four indirection operators: @,*%,*&, and *!. These are _similar_
  683. to pointers in C.
  684.  
  685.     @<object>   - returns the absolute address of a data object or SUB.
  686.             - note that this is identical to VARPTR(<object>).
  687.     *%<address> - peeks or pokes a short value at the specified address.
  688.     *&<address> - peeks or pokes a long value at the specified address.
  689.     *!<address> - peeks or pokes a single value at the specified address.
  690.  
  691. The indirection operators can therefore be used in a statement (poke) and/or 
  692. as part of an expression (peek), for example:
  693.  
  694.     address x
  695.     y=23.25
  696.     x=@y
  697.     *!x := *!x + 2
  698.     print y
  699.  
  700. will print a value of 25.25.
  701.  
  702. There are two things to notice here. First, the pointers are to addresses, 
  703. not necessarily connected to variables. It would be quite legal to allocate
  704. an area of memory and then dereference it with these operators.
  705.  
  706. Second, when assigning a value to a dereferenced memory location as in the 
  707. above example, the ":=" symbol must be used, simply because of the way the 
  708. parser processes statements. Pascal programmers will recognise this as 
  709. the assignment operator. 
  710.  
  711. See also the section below for information about how to use these operators
  712. to implement variable parameters (call-by-reference) for simple variables in 
  713. ACE subprograms.
  714.  
  715.  
  716. $$Identifiers
  717. -----------
  718. As in AmigaBASIC an identifier can consist of a combination of letters, 
  719. numbers and periods (".") up to a maximum length of 40 characters. 
  720.  
  721. In ACE the underscore ("_") character is also legal. An ACE identifier must 
  722. start with either a letter or an underscore character.
  723.  
  724. An identifier can be used to represent the following:
  725.  
  726.         - labels
  727.         - arrays
  728.         - variables
  729.         - parameters
  730.         - structures
  731.         - subprograms
  732.         - defined functions
  733.         - named constants
  734.         - shared library functions
  735.         - external functions and variables
  736.  
  737. Note that in ACE, a simple variable and an array with the same name
  738. cannot coexist. For example, a single-precision variable V cannot
  739. coexist with a single-precision array, eg: DIM V(100). However 'V!' *can*
  740. live with V(100) since V and V! are different variables in ACE. See the 
  741. discussion of qualifier characters below.
  742.  
  743. Labels are global in ACE, so a main program label and a SUB label cannot 
  744. have the same name. The format for a label definition is:
  745.  
  746.     <name>:
  747.  
  748. Labels are used by GOTO and GOSUB. For example:
  749.  
  750.     GOSUB HaveSomeFun
  751.     STOP
  752.  
  753.     HaveSomeFun:
  754.         PRINT "Are we having fun yet?"
  755.     RETURN
  756.         
  757. Identifiers can have a qualifier character (%&$!#) appended in order to 
  758. indicate data type, where:
  759.  
  760.         % = short integer
  761.         & = long integer
  762.         ! = single-precision
  763.         # = double-precision -> not supported yet
  764.         $ = string    
  765.  
  766. Examples of valid identifiers are:
  767.  
  768.         x3
  769.         num&
  770.         _putchar
  771.         play.sound
  772.  
  773. An identifer with no qualifier has a default type of single-precision. The 
  774. DEFxxx compiler directives (see command and function reference) have the
  775. same effect as the qualifier characters except they affect all identifiers
  776. starting with a certain letter. Qualifier characters have higher priority
  777. than DEFxxx directives. 
  778.  
  779. For shared library functions and external references, a qualifier is used 
  780. merely to declare data type. So for example, an external function might be 
  781. declared thus:
  782.  
  783.         external function RangeRand%
  784.  
  785. but can later be referred to as RangeRand.
  786.  
  787. The declaration of external functions/variables and shared library functions
  788. is global no matter where the declaration occurs.
  789.  
  790. Defined constants are unaffected by qualifier characters. The _value_ of a 
  791. defined constant determines its type. Thus CONST x&=1.2 is a single-precision
  792. - NOT a long integer - constant. Needless to say therefore, it is unwise to
  793. use qualifier characters for named constants.
  794.  
  795. The declaration of constants (with CONST) is always global whether the
  796. declaration takes place in the main program or a subprogram.
  797.  
  798. Structure variables hold a long integer value (address), so trailing 
  799. characters have no effect.
  800.  
  801. Structure type definitions are global, but structure variable declarations
  802. are local.
  803.  
  804. ACE allows for *optional* variable declarations with the SHORTINT, LONGINT,
  805. ADDRESS, SINGLE and STRING directives. Such declarations are useful in that:
  806.     
  807.         (i)    They ensure that a variable has a NULL or zero 
  808.             value.
  809.  
  810.         (ii)    They prevent dangerous errors which result from 
  811.             the misspelling of variable names.
  812.  
  813.         (iii)    Most languages have them and they serve to 
  814.             document variable usage explicitly.
  815.  
  816.         (iv)    They provide a "cleaner" way of establishing a 
  817.             variable which is to be shared by a subprogram
  818.             in ACE.
  819.  
  820. My feeling on the matter of variable declarations is that in a small program 
  821. they probably aren't necessary so long as you are careful, but in a large 
  822. program all major variables should be declared for safety. I plan to add a
  823. compiler switch which could be used to enforce mandatory variable declarations.
  824.   
  825. Variable declarations override the DEFxxx compiler directives and qualifier
  826. characters and are local to the current level (main program or subprogram).
  827.  
  828. Summary of identifier properties:
  829.  
  830. +---------------+---------------+------------------+
  831. | Identifier    | Local/Global  | Affected by %&!$ |
  832. +---------------+---------------+------------------+
  833. | ARRAY        | LOCAL        | YES            |
  834. | SIMPLE VAR    | LOCAL        | YES           |
  835. | STRUCTURE VAR | LOCAL        | NO           |            
  836. | PARAMETER    | LOCAL        | YES           |
  837. | STRUCTURE DEF | GLOBAL    | NO           |        
  838. | LABEL        | GLOBAL    | NO           |
  839. | NAMED CONST   | GLOBAL    | NO           |
  840. | SUBPROGRAM     | GLOBAL    | YES           |
  841. | DEF FN     | GLOBAL    | YES           |
  842. | LIBRARY FUNC  | GLOBAL    | YES (declaration)|
  843. | EXT VAR/FUNC    | GLOBAL    | YES (declaration)|
  844. +---------------+---------------+------------------+
  845.  
  846.    
  847. $$Sequential Files
  848. ----------------
  849. AmigaBASIC sequential files are supported and random files are on the list 
  850. of things to do.
  851.  
  852. The commands and functions for manipulating sequential files in ACE are:
  853.  
  854. commands:
  855.     - OPEN
  856.     - CLOSE
  857.     - PRINT#
  858.     - WRITE#
  859.     - INPUT#
  860.     - LINE INPUT#
  861.  
  862. functions:
  863.     - INPUT$ 
  864.     - EOF
  865.     - LOF
  866.     - HANDLE *
  867.  
  868.     * not found in AmigaBASIC
  869.  
  870. Note that for any command which is immediately followed by a # there should 
  871. be at least one space between the keyword and the #, even though I may refer 
  872. to such commands as <name># in the text of this document and in ref.doc.
  873.  
  874. See the command and function reference for details of each of these.
  875.  
  876. When WRITE# is used, the result is identical to AmigaBASIC. For example:
  877.  
  878.     X=12 : Y=-3.2 : Z$="fun eh?"
  879.     OPEN "O",#1,"stuff"
  880.       WRITE #1,X,Y,Z$
  881.     CLOSE #1
  882.  
  883. results in a one-line file of the following format:
  884.  
  885.     12,-3.2,"fun eh?"
  886.  
  887. On the other hand, if the following is used instead: 
  888.  
  889.     PRINT #1,X,Y,Z$ 
  890.  
  891. the file format will be:
  892.  
  893.      12         -3.2        fun eh?
  894.  
  895. while if semicolons are used:
  896.  
  897.     PRINT #1,X;Y;Z$
  898.  
  899. the file format becomes:
  900.  
  901.      12 -3.2 fun eh?
  902.  
  903. INPUT# (eg: INPUT #1,X,Y,Z$) can be used to read values from a file in any 
  904. of the above formats, but bear in mind that strings that are not delimited
  905. by quotes, but contain spaces or tabs will be seen as more than one string 
  906. by INPUT#. So, in the example formats above, while 
  907.  
  908.     "fun eh?" 
  909.  
  910. is one string,
  911.  
  912.     fun eh?
  913.  
  914. is two strings as far as INPUT# is concerned.
  915.  
  916. The formats of sequential files in ACE and AmigaBASIC are now very nearly
  917. identical, the only differences being in ACE tabs (produced by comma 
  918. delimiters in PRINT -- see PRINT in ref.doc) and the number of decimal 
  919. places written for single-precision values (usually more in ACE).
  920.   
  921. If you find ACE file I/O too slow, you may want to use the dos.library 
  922. functions (eg: xRead, xWrite). For this reason, I have included the HANDLE 
  923. function which returns the AmigaDOS handle of a file opened with ACE's OPEN 
  924. command. You may also wish to use the ami.lib buffered file I/O functions 
  925. which also require this handle. If HANDLE returns 0, the file can't be opened.
  926.  
  927. See prgs/IO/print.b for an example of opening a sequential file to a printer. 
  928.  
  929. Although SER: may be opened as a sequential file, it is not possible to 
  930. specify parameters for the serial port (baud rate etc) by this method as 
  931. is possible in AmigaBASIC.
  932.  
  933. Instead, ACE provides a set of special serial I/O commands. See ref.doc for 
  934. details of SERIAL OPEN/CLOSE etc, and prgs/IO/aterm.b for a simple terminal 
  935. program.
  936.  
  937.  
  938. $$Random Files
  939. ------------
  940. ACE's random files depart from AmigaBASIC's in a number of ways. I believe
  941. that the result is cleaner, and more programmer-friendly than AmigaBASIC's 
  942. random files.
  943.  
  944. The major design goals for random files in ACE were: run-time efficiency,
  945. simplicity, and flexibility, all of which have been achieved.
  946.  
  947. Quite some time was spent in deciding what would be the best approach 
  948. would be. For comparison, here are the commands and functions necessary
  949. to do random files in AmigaBASIC:
  950.  
  951.     CVD    MKD$
  952.     CVI    MKI$    
  953.     CVL    MKL$
  954.     CVS    MKS$
  955.     FIELD    OPEN
  956.     GET    PUT
  957.     LOC    RSET
  958.     LSET
  959.  
  960. In ACE, the following are all that's required:
  961.  
  962.     GET
  963.     LOC
  964.     OPEN
  965.     PUT
  966.  
  967. In common with both sequential and random files are commands/functions 
  968. like CLOSE, and LOF which may be used in the same way with either file
  969. type.
  970.  
  971. How is this possible, you ask? ACE structures (see the section below on 
  972. "Structures") are used as the basic unit of storage for the records of 
  973. random files. Indeed, the effect of the AmigaBASIC FIELD, MKx$, CVx, 
  974. LSET, and RSET commands is to build and modify an internal data structure
  975. for a random file, which in essence, _is_ a structure. ACE simply makes
  976. this explicit and removes from the programmer, the burden of having to
  977. worry about the conversion of data to a form suitable for writing to or
  978. reading from a random file.
  979.  
  980. So, for example, take the following structure definition and variable
  981. declaration:
  982.  
  983.     Struct person
  984.         String theName Size 20
  985.         String phoneNum Size 16
  986.         Shortint age
  987.     End Struct
  988.  
  989.     Declare Struct person X,Y
  990.  
  991. A random file could be opened and a record written thus:
  992.  
  993.     Open "R",#1,"ram:people.db"
  994.     If Err = 0 Then 
  995.         X->theName = "David Benn
  996.         X->phoneNum = "261 461"
  997.         X->age = 32
  998.         Put #1,X    '..the record number is optional.
  999.       Close #1
  1000.     End If  
  1001.  
  1002. The first (and only) record could then be read like this:
  1003.  
  1004.     Open "R",#1,"ram:people.db"
  1005.     If Err = 0 Then
  1006.           Get #1,Y    '..the record number is optional.
  1007.           bytesRead = Loc(1)
  1008.           Print "<<Record";Str$(bytesRead\Sizeof(Y));">>"
  1009.           Print " Name: ",Y->theName
  1010.           Print "Phone: ",Y->phoneNum
  1011.           Print "  Age: ",Y->age
  1012.           Print
  1013.       Close #1
  1014.     End If  
  1015.  
  1016. Also, reading and writing can take place on the same open file.
  1017.  
  1018. So, what's the downside?
  1019.  
  1020. ACE random files are not binary-compatible with AmigaBASIC random files. 
  1021. AmigaBASIC random file records are similar to ACE's, but not identical. 
  1022. The main differences are:
  1023.  
  1024.     - In AmigaBASIC, strings are not ASCII-zero terminated as in ACE, 
  1025.       and are padded with spaces to the right or left in each random 
  1026.       file record using RSET or LSET. 
  1027.  
  1028.     - AmigaBASIC and ACE floating-point values have a different format
  1029.       since the latter uses standard Amiga libraries for floating-point
  1030.       math, while the former uses a proprietary Microsoft format.
  1031.        
  1032. If necessary, a program could be written to convert AmigaBASIC random files 
  1033. to ACE's format and vice-versa.
  1034.        
  1035. ACE random files are flexible because it is possible to have multiple
  1036. structure types in a single random file. They are efficient because there
  1037. is a 1:1 correspondence between a given structure and random file record.
  1038. They are also simple for this reason and because few commands and functions
  1039. are needed.
  1040.  
  1041. See ACE:prgs/IO/rfile.b for an example program, and carefully read the
  1042. section on "Structures" below. See ref.doc for the details of CLOSE, GET,
  1043. LOC, LOF, OPEN, and PUT. See also ERR for error codes relating to random
  1044. files.
  1045.  
  1046.     
  1047. $$Command line and Workbench arguments
  1048. ------------------------------------
  1049. When invoked from a Shell or CLI, an ACE program may have arguments, eg:
  1050.  
  1051.     tree 30
  1052.  
  1053. Arguments can be accessed by two ACE functions:
  1054.  
  1055.     ARGCOUNT and ARG$(n)
  1056.  
  1057. The former returns a short integer value indicating the number of arguments
  1058. for the current program, while the latter returns the nth argument as a string
  1059. where n ranges from 0 to argcount. The zeroth argument (ie. ARG$(0)) is the 
  1060. name of the program.
  1061.  
  1062. Workbench arguments are currently supported by ACE in the form of four 
  1063. functions in the WBarg SUBmod: WBargcount, WBarg$(n), WBargPath$(n) and
  1064. WBargLock&(n).
  1065.  
  1066. The first three are the most useful. The fourth is mainly for use by 
  1067. WBargPath$. 
  1068.  
  1069. WBargcount returns the number of arguments passed to a program. This includes
  1070. the program name.
  1071.  
  1072. As with ARG$(0), the zeroth Workbench argument is the name of the program.
  1073.  
  1074. To pass arguments to a program via Workbench one of the shift keys is held 
  1075. down while the icons which represent the arguments to be passed are activated.
  1076. While still depressing the shift key, the application icon is double clicked. 
  1077.  
  1078. An alternative method of passing arguments is to change the default tool of a 
  1079. project icon (eg: document) with the Info option from Workbench.
  1080.  
  1081. When this project icon is double clicked, the default tool will be loaded.
  1082. In this case, if the source code of the default tool (the program) had a line 
  1083. such as:
  1084.  
  1085.     x$ = WBarg$(1)
  1086.  
  1087. x$ would contain the name of the project file.
  1088.  
  1089. WBargPath$(n) is used to find the full path of the file name and includes 
  1090. trailing ":" and "/" characters.
  1091.  
  1092. This SUBmod also has functions for handling ToolTypes: ToolTypeVal$,
  1093. ToolTypeMatched, and DefaultTool$.
  1094.  
  1095. See the source code and example programs in SUBmods/WBarg for more.
  1096.  
  1097.       
  1098. $$Subprograms
  1099. -----------
  1100. Subprograms are supported by ACE, but differ from AmigaBASIC subprograms in
  1101. a number of ways. Namely, ACE subprograms:
  1102.  
  1103.     - Don't use the STATIC keyword,
  1104.     - Allow recursion,
  1105.        - Can return values.
  1106.  
  1107. ACE subprograms don't make use of the STATIC keyword because they are non
  1108. static. This means that between calls to a specific subprogram, variables
  1109. local to the subprogram cease to retain any meaningful value since the 
  1110. memory used to store them may be reused for other purposes.
  1111.  
  1112. Recursive subprograms are an important feature of modern general programming 
  1113. languages. For several examples of the use of recursion, see the included 
  1114. programs (eg: fact.b, hanoi.b, tree.b). See also the WBarg SUBmod.
  1115.  
  1116. A word of warning about recursion: it can be stack hungry, so it's a good 
  1117. idea to set your stack to 20000 or so, just to be safe, although in most 
  1118. cases, this will be a lot more than you need. From Workbench, simply change 
  1119. the tool's stack size with Info, or with the STACK command in a shell.
  1120.  
  1121. As with AmigaBASIC, ACE subprogram declarations cannot be nested.
  1122.  
  1123. The syntax of a subprogram call is the same as in AmigaBASIC:
  1124.  
  1125.     [CALL] sub-name[(parameter-list)]
  1126.  
  1127. The only difference is that the parentheses around the parameter list are
  1128. not optional when CALL is omitted -- unless there are NO parameters. 
  1129.  
  1130. CALL *must* be used after THEN in a single-line IF..THEN statement.
  1131.  
  1132. By default, every subprogram has a return type of single-precision (just like 
  1133. variables). The DEFxxx directives can be used to change the default data type 
  1134. of subprograms, as can the trailing characters !#$&%. A subprogram name can
  1135. also be preceded by SHORTINT,LONGINT,ADDRESS,SINGLE or STRING as yet another
  1136. alternative to setting the subprogram's return type.
  1137.  
  1138. The fact that ACE subprograms can be easily used as functions pretty much 
  1139. obviates the need for DEF FN. However for reasons of compatibility with 
  1140. AmigaBASIC and other BASICs, as well as its utility for simple functions, 
  1141. ACE supports DEF FN (as of ACE v2.0). 
  1142.  
  1143. A subprogram is given a value either inside the body of the relevant 
  1144. subprogram or in the main program (eg: to zero it) - ala Pascal - thus:
  1145.  
  1146.     sub-name = <expression>
  1147.  
  1148. However, subprograms cannot be assigned a value in any other way (eg: with
  1149. INPUT or READ).
  1150.  
  1151. A subprogram can be used in an expression, whereupon the subprogram is called
  1152. and its value pushed onto the stack for inclusion in the final result of the
  1153. expression, eg:
  1154.  
  1155.     x = n*pow(n)
  1156.  
  1157. where "pow" is a subprogram with one parameter.
  1158.  
  1159. While subprogram declarations can appear anywhere within the program text,
  1160. ACE requires that declarations precede calls. So:
  1161.  
  1162.     sub test
  1163.       print "hello"
  1164.      end sub
  1165.  
  1166.     test
  1167.  
  1168. is legal, but:
  1169.  
  1170.     test
  1171.  
  1172.     sub test
  1173.       print "hello"
  1174.      end sub
  1175.  
  1176. is not, and will yield an "undeclared subprogram" error. To get around this, 
  1177. a forward declaration can be used:
  1178.  
  1179.     declare sub test
  1180.     
  1181.     test
  1182.  
  1183.     sub test
  1184.       print "hello"
  1185.     end sub
  1186.  
  1187. Forward declarations can include a parameter list. If you later declare
  1188. the actual SUB with a different parameter list and you've already called 
  1189. the subprogram after a forward declaration, the results will be unpredictable.
  1190. I may place tighter controls on this at some stage.
  1191.  
  1192. Actual parameters are checked for number and type against formals, and 
  1193. parameter count mismatches result in a compilation error. Actual parameters
  1194. are coerced to the corresponding formal parameter's type.
  1195.  
  1196. ACE's parameter passing mechanism for subprograms is NOT the same as that
  1197. used for assembly code routines or C functions. In other words, the standard 
  1198. C parameter passing mechanism is not used for SUBs. This may be changed in 
  1199. the future as it makes object modules written in ACE incompatible with C or 
  1200. assembler object modules in this respect.
  1201.   
  1202. Changes made to a formal parameter have no effect upon the actual parameter 
  1203. in a simple call to an ACE subprogram, but see "Limitations" re: overwriting 
  1204. of strings/arrays during recursive calls; see also "Structures" below. 
  1205.  
  1206. The formal parameter list consists of identifiers separated by commas. Each 
  1207. identifier may also be preceded by: SHORTINT,LONGINT,ADDRESS,SINGLE or STRING 
  1208. to avoid the use of a qualifier (%&!$).
  1209.  
  1210. Actual parameters can basically be any type of expression. A whole array 
  1211. cannot be passed as a value parameter in ACE however.
  1212.  
  1213. There is an arbitrary upper limit of 40 parameters per subprogram at the
  1214. moment, which may be removed at some stage.
  1215.  
  1216. Main program variables and arrays can be accessed and modified within 
  1217. subprograms via the SHARED directive. All shared variables are passed by 
  1218. reference to a subprogram.
  1219.  
  1220. Multiple SHARED statements are allowed within a single subprogram.
  1221.  
  1222. DIM SHARED is not allowed. An array is declared to be shared in exactly the 
  1223. same way as simple variables, for example:
  1224.  
  1225.     DIM x(10)
  1226.  
  1227.     sub thing
  1228.         shared x
  1229.         .
  1230.         .
  1231.         end sub
  1232.  
  1233. Note that parentheses are not required after an array in the shared statement, 
  1234. nor are they legal in ACE.
  1235.  
  1236. Keep the following in mind with regard to shared variables in ACE:
  1237.  
  1238.     - Shared variables only allow access to main program
  1239.       variables from a subprogram, and do not provide a
  1240.       mechanism for changing the value of variables in 
  1241.           one subprogram from another.  
  1242.  
  1243.         - The name of a variable to be shared must correspond
  1244.       to the name of an existing (ie: already referenced/declared) 
  1245.           main program variable.
  1246.  
  1247. Although variable parameters are not explictly provided by ACE there are 
  1248. two ways to implement them: using indirection operators for simple variables 
  1249. and the ADDRESS option of DIM and STRING (see also "Structures" section).
  1250.  
  1251. Here's an example of call-by-reference parameters for simple variables:
  1252.  
  1253.     sub doub(address x)
  1254.        *!x := *!x * 2    '..n! = n!*2 [note the ":=" symbol!]
  1255.     end sub
  1256.  
  1257.     n!=22.5
  1258.     print n!
  1259.     doub(@n!)  '..pass the address of n!
  1260.     print n!
  1261.  
  1262. which passes the single-precision variable n by reference to the subprogram 
  1263. doub, where n is doubled. This will first print 22.5 and then 45.
  1264.  
  1265. For an array, the following can be done:
  1266.  
  1267.     sub test(address x)
  1268.     dim a(10) address x  
  1269.       a(3)=a(3)+12
  1270.     end sub
  1271.  
  1272.     dim n(10)
  1273.     n(3)=2
  1274.     print n(3)
  1275.     test(@n)    '..pass address of array n.
  1276.     print n(3)
  1277.  
  1278. which would print first 2 and then 14.
  1279.  
  1280. The same mechanism can be used to pass a string variable by reference (see
  1281. the STRING command's ADDRESS option).
  1282.  
  1283. These variable parameter mechanisms are most useful when used to pass data 
  1284. *between* subprograms, otherwise it is simpler to use SHARED variables.
  1285.    
  1286. The following table shows the possibilities regarding parameters and shared 
  1287. variables in ACE:
  1288.  
  1289. +---------------------+---------+-------------+------------------------------+
  1290. | Data Type / Object  |    Shared     | Value param | Call by Reference parameter  |
  1291. +---------------------+---------+-------------+------------------------------+
  1292. | SHORTINT VARIABLE   |    YES        | YES          |    YES - *%addr                 |
  1293. |              |             |          |                     |
  1294. | LONGINT/ADDRESS VAR |    YES     | YES          |    YES - *&addr                 |
  1295. |              |            |          |                         |
  1296. | SINGLE VARIABLE     |    YES     | YES          |    YES - *!addr                 |
  1297. |              |            |          |                         |
  1298. | STRING VARIABLE     |    YES    | YES          |    YES - STRING x ADDRESS addr  |
  1299. |              |        |          |                         |
  1300. | EXTERNAL VARIABLE   |    NO    | YES          |    YES - *%, *&, *!, STRING ..  |
  1301. |              |        |          |                     |
  1302. | ARRAY              |    YES    | NO          |    YES - DIM x ADDRESS addr     |
  1303. |              |        |          |                         |
  1304. | STRUCTURE          |    YES    | NO          |    YES - See "Structures" below |
  1305. +---------------------+---------+-------------+------------------------------+
  1306.  
  1307. Note: In the above table, "addr" is a long integer address. VARPTR or @ 
  1308. can be used to obtain this.
  1309.  
  1310.     
  1311. $$Structures
  1312. ----------
  1313. Structures have been included in ACE mainly because of their utility in 
  1314. gaining access to operating system functions. 
  1315.  
  1316. Structure members may be of the following type: BYTE (in structures only),
  1317. SHORTINT, LONGINT, ADDRESS, SINGLE, STRING. The latter can have an optional 
  1318. size specification. A structure may also have as a member another structure. 
  1319.  
  1320. If you want to have a pointer to a structure (or a pointer to anything else) 
  1321. as a member, simply declare it to be of type ADDRESS.
  1322.  
  1323. Allowing structures to have other structures as members makes converting 
  1324. system structures from C to ACE much easier than it otherwise would be, eg:
  1325.  
  1326.     STRUCT DateStamp
  1327.        LONGINT days
  1328.       LONGINT secs
  1329.       LONGINT ticks
  1330.       END STRUCT
  1331.  
  1332.     STRUCT myFirstStruct
  1333.       DateStamp ds
  1334.       STRING name SIZE 30
  1335.     END STRUCT
  1336.  
  1337.     DECLARE STRUCT myFirstStruct mine
  1338.     DECLARE STRUCT DateStamp *myDate
  1339.     
  1340.     .
  1341.     .
  1342.  
  1343.     myDate = @mine->ds    '..assign address of mine->ds to myDate.
  1344.     myDate->days = 23
  1345.  
  1346.     .
  1347.     .
  1348.  
  1349. If an array is required as a structure member, it is currently necessary 
  1350. to use STRING <ident> SIZE <bytes>. Most system structures use character
  1351. arrays (strings) anyway. As an example, if you wanted a SHORTINT array 
  1352. member with 50 elements (0..49) you could say:
  1353.  
  1354.     STRUCT mySecondStruct
  1355.       STRING myArray SIZE 100    '..reserve space for the array
  1356.       .
  1357.       .
  1358.     END STRUCT
  1359.     
  1360.     DECLARE STRUCT mySecondStruct aStruct
  1361.  
  1362.     DIM N%(100) ADDRESS @aStruct->myArray
  1363.  
  1364. You can of course use SIZEOF to determine the number of bytes ACE would
  1365. set aside for a particular array. A two line program would accomplish
  1366. this:
  1367.  
  1368.     DIM a_short_array%(49)
  1369.     PRINT SIZEOF(a_short_array%)
  1370.  
  1371. The value thus derived can then be used when declaring a structure such
  1372. as the one shown above.
  1373.  
  1374. Note that in the case of the array and structure members above, it is 
  1375. necessary to take the address of the member and assign it to a normal
  1376. array or structure (pointer to structure - see below) variable. 
  1377.  
  1378. When declaring a structure, the only difference between the following two
  1379. forms:
  1380.  
  1381.         DECLARE STRUCT mystructtype mystruct
  1382.     and
  1383.         DECLARE STRUCT mystructtype *mystruct
  1384.  
  1385. is that for the former, an appropriate data object is created (on a long
  1386. word boundary), but not for the latter.
  1387.  
  1388. In both cases, mystruct contains the start address of a structure of type 
  1389. mystructtype. In the second case, the address is NULL until assigned a value 
  1390. (eg: with ALLOC). In both cases, the address can be reassigned at will, 
  1391. although this should only really be done for structure pointers (the second
  1392. form).
  1393.  
  1394. Since both forms of structure declaration result in an address being stored
  1395. (in mystruct in the example), the dereferencing operator is always "->".
  1396.  
  1397.     examples:
  1398.     --------
  1399.  
  1400.     PRINT mystruct          -  prints the start address of the structure.
  1401.  
  1402.     PRINT mystruct->mins -     prints the value of a member called mins.
  1403.   
  1404. The SIZEOF function can be used to determine the size of a structure type
  1405. if allocating memory for a structure (see prgs/misc/linkedlist.b).
  1406.  
  1407. ACE structures are stand-alone data objects, and cannot be elements in an 
  1408. array, although structure *addresses* _can_ be. For an example of the 
  1409. latter, see prgs/misc/array_of_structs.b.
  1410.  
  1411. An ACE structure can be SHARED to allow its member's values to be modified, 
  1412. or a structure's address can be passed to a subprogram, eg:
  1413.  
  1414.     struct my
  1415.        longint one
  1416.        longint two
  1417.     end struct
  1418.     
  1419.     sub test(addr&)
  1420.     declare struct my *second
  1421.        second=addr&
  1422.        second->one = second->one * 2
  1423.     end sub
  1424.  
  1425.     '..main
  1426.     declare struct my first
  1427.     first->one=12
  1428.     print first->one
  1429.     test(first)
  1430.     print first->one
  1431.  
  1432. which will print 12 followed by 24.
  1433.  
  1434. The following code allocates enough memory to hold a structure of type "my", 
  1435. gives values to the structure's 2 members, and changes the address held by 
  1436. the structure variable "third" to the start of the newly allocated memory 
  1437. area:
  1438.  
  1439.     declare struct my *third
  1440.  
  1441.     sub create(ADDRESS a_struct)
  1442.     declare struct my *temp
  1443.       temp = ALLOC(sizeof(my))
  1444.       temp->one = 16
  1445.       temp->two = 10
  1446.       *&a_struct := temp    '..change structure variable's value
  1447.     end sub
  1448.  
  1449.     '..main
  1450.     create(@third)
  1451.     .
  1452.     .
  1453.  
  1454. One word of caution. ACE makes no attempt to align data on word boundaries 
  1455. within a structure, so make sure that Shortint, Longint or Address members
  1456. start at an offset from the start of the structure which is a multiple of
  1457. the size of the data member in question (check with Print Sizeof(Shortint)
  1458. or Print Sizeof(Longint) etc if in doubt). If alignment is out, the assembler
  1459. will complain. ACE _does_ long-word align a static structure's start address 
  1460. however, and assigning to structure pointer variables results in long-word
  1461. aligned structures when using ACE's ALLOC or Exec's AllocMem() etc. 
  1462.  
  1463. Finally, it is not currently possible to use INPUT, (LINE) INPUT# or READ 
  1464. in conjunction with structures.
  1465.  
  1466.     
  1467. $$Shared library function calls
  1468. -----------------------------
  1469. ACE provides access to shared libraries in the same way as AmigaBASIC does
  1470. with the exception that you MUST declare a function in order to use it. 
  1471.  
  1472. Also, the library in question must either be in LIBS: or in ROM.
  1473.  
  1474. As of version 2.0, ACE and AmigaBASIC are otherwise pretty much the same. 
  1475. The ACE commands also retain their earlier syntax for backward compatibility 
  1476. and convenience.
  1477.  
  1478. The commands are as follows:
  1479.  
  1480. LIBRARY <libname>    
  1481.  
  1482.     - Where <libname> is the name of a shared library with or 
  1483.       without quotes (eg: "graphics", "graphics.library", graphics).
  1484.  
  1485.     - A ".library" or ".bmap" suffix is allowed but optional.
  1486.  
  1487.            - The LIBRARY command opens the shared library and provides
  1488.       a copy of its base address for use internally by function 
  1489.       calls.
  1490.  
  1491.     - If a library can't be opened at run-time, the program 
  1492.       will abort.
  1493.  
  1494.  
  1495. LIBRARY CLOSE [<libname>]
  1496.  
  1497.     - Closes the specified shared library or all open libraries
  1498.       if no library name is given.
  1499.  
  1500.     - Closing a library more than once will cause no harm.
  1501.  
  1502.  
  1503. Notes about standard libraries used by ACE:
  1504.  
  1505.     - There are currently six standard libraries which are often opened 
  1506.       by ACE routines during a program run. These are: dos, intuition,
  1507.       graphics, mathffp, mathtrans and translator libraries.
  1508.  
  1509.     - If one of these six is opened by the LIBRARY command it will 
  1510.       be opened at the start of the program *and* closed at the end. 
  1511.       Any other library will be opened and closed at the points in 
  1512.       the program specified by you.
  1513.  
  1514.     - You don't actually have to close any of the six libraries 
  1515.       mentioned above, but it won't hurt.
  1516.  
  1517.     - Moreover, you never have to open or close the dos.library
  1518.       since ACE opens it for EVERY program.
  1519.  
  1520.  
  1521. DECLARE FUNCTION <funcname>[%&!#$][(param-list)] LIBRARY [<libname>]
  1522.         
  1523.     - Where <funcname> is the case sensitive name of a function in a
  1524.       shared library.
  1525.  
  1526.     - <funcname> may have a trailing character (&%#!$) to indicate type,
  1527.       otherwise default data type rules apply for the function's return 
  1528.       value. This character is optional when CALLing the function.
  1529.  
  1530.     - The optional parameter-list is for documentation purposes only
  1531.       and is otherwise ignored.
  1532.  
  1533.     - If <libname> (same as for LIBRARY and LIBRARY CLOSE) is specified, 
  1534.       ACE only looks in the bmap file for that library, otherwise ACE
  1535.       looks for the function in the bmap files for all open libraries 
  1536.       and all the standard libraries known to the compiler. Needless 
  1537.       to say that specifying <libname> results in faster bmap file
  1538.       entry lookups. This option is not given by AmigaBASIC however.
  1539.  
  1540.     - Example: DECLARE FUNCTION SetSoftStyle LIBRARY
  1541.  
  1542.  
  1543. [CALL] <funcname>[(parameter-list)]
  1544.  
  1545.     - Transfers control to the function <funcname>, loading the
  1546.       appropriate registers before doing so, according to the
  1547.       information about that function in the library's bmap file. 
  1548.  
  1549.      - The return value of a function can be accessed by calling
  1550.       a function as part of an expression, eg: addr& = AllocMem(100,2).
  1551.  
  1552. Function declarations are GLOBAL. They are are NOT optional in ACE.
  1553.  
  1554. ** PLEASE NOTE ***
  1555. No type checking of parameters is performed, so expect weirdness if you pass
  1556. values of the wrong type to a shared library function. ACE _does_ however now 
  1557. automatically promote all short integers to long integers by sign-extension.
  1558.  
  1559. When passing strings as parameters it is not necessary to add a CHR$(0)
  1560. to the end of a string since ACE strings are already NULL terminated. 
  1561.  
  1562. Either VARPTR or SADD can safely be used to find the address of a string 
  1563. variable or constant. Actually, the use of SADD or VARPTR for strings
  1564. passed to library functions is optional, but it's probably a good idea to 
  1565. use one or the other all the time, for consistency's sake. These comments 
  1566. also apply to calling machine code routines and external functions.
  1567.   
  1568. It is up to YOU to open and close libraries correctly. ACE doesn't keep
  1569. track of this, and will try to jump to a library function so long as 
  1570. it finds a reference to it in a bmap file even if the library hasn't 
  1571. been opened! As mentioned above, it is not necessary to open and close 
  1572. dos.library because _every_ ACE program does this.
  1573.  
  1574. ACE expects the bmap file for a library to be in the directory ACEbmaps:
  1575. (see "Installation"). As of version 2.37 these are supplied with the ACE
  1576. distribution for the standard Amiga shared libraries. In addition to these 
  1577. are a complete set of header files translated from the original C headers. 
  1578. In no way are these necessary to use shared library function in ACE but for 
  1579. serious system-level work they are highly recommended. 
  1580.  
  1581. Be aware that while the bmap files in ACEbmaps: cater for all operating
  1582. system versions from 1.3 through to 3.0, some library functions may not be 
  1583. supported on the machine you're compiling programs for. The same is true of
  1584. the header files in ACEinclude:.
  1585.  
  1586. As of version 2.0, I have provided a program (FD2BMAP) which is functionally 
  1587. equivalent to ConvertFD (since this may NOT be freely redistributed) so that 
  1588. bmap files for new libraries can be created. The program FD2BMAP can be found 
  1589. in the ACE:utils/fd2bmap directory and was written in ACE by Harald Schneider, 
  1590. with some modifications from me.
  1591.  
  1592. The 1.3 FD files can be found in the BasicDemos drawer on the Extras disk. 
  1593.  
  1594. AmigaBASIC cannot handle functions which use address register a5. This is 
  1595. not true for ACE. Neither ACE nor AmigaBASIC allow the use of functions which
  1596. use register a6 however.
  1597.  
  1598. See the programs in prgs/Library for examples of how to use shared library 
  1599. functions in ACE.
  1600.  
  1601.   
  1602. $$Machine code calls
  1603. ------------------
  1604. ACE supports AmigaBASIC's mechanism for calling machine code routines and
  1605. the passing of parameters to such routines. AmigaBASIC's stack conventions 
  1606. are also followed (ie: C style parameter passing).
  1607.  
  1608. The syntax for calling such a routine is:
  1609.  
  1610.     CALL long-integer-variable-name[(parameter-list)]
  1611.  
  1612. Note that CALL is NOT optional. Also, the variable containing the address 
  1613. of the routine *must* be a long integer (LONGINT or ADDRESS) in ACE.
  1614.  
  1615. For example, 
  1616.  
  1617.     CALL caps&(length&,addr&)
  1618.  
  1619. will set up the stack like this:
  1620.     
  1621.     8(sp) = addr&
  1622.     4(sp) = length&
  1623.     0(sp) = return address
  1624.  
  1625. on entry to the machine code subroutine caps&.
  1626.  
  1627. On exit from a routine, ACE cleans up the stack by POPping all parameters.
  1628.  
  1629. You can use a short integer array, a string or an allocated area of memory
  1630. (eg. with ACE's ALLOC function) to poke the bytes of a machine code routine 
  1631. into. I prefer the latter method.
  1632.  
  1633. Note that because ACE treats ASCII 0 as the end-of-string character, don't 
  1634. use the string-building method, eg:
  1635.  
  1636.     z$=""
  1637.     for i=1 to N
  1638.          read b
  1639.       z$=z$+chr$(b)
  1640.         next
  1641.  
  1642. since if b=0, chr$(b) will be the NULL string. If you want to use a string,
  1643. do the following:
  1644.  
  1645.     z$=""    '..or STRING z$ SIZE 100 (if there are 100 bytes of MC).
  1646.     addr&=sadd(z$)
  1647.     for i&=0 to N-1
  1648.       read b%
  1649.       poke addr&+i&,b%
  1650.     next
  1651.     call addr&
  1652.  
  1653. The latter is okay, so long as you don't allocate other strings with odd 
  1654. sizes. But if you want to be sure that you have an area of memory which 
  1655. is long-word aligned, use ALLOC (or AllocMem), eg:
  1656.  
  1657.     addr&=Alloc(100)    '..100 bytes of ANY memory
  1658.     for i&=0 to N-1
  1659.       read b%
  1660.       poke addr&+i&,b%
  1661.     next
  1662.     CALL addr&
  1663.  
  1664. The above examples assume the presence of appropriate DATA statements. See 
  1665. the prgs/MC directory for examples.
  1666.  
  1667. ACE also supports primitive inline assembly code inclusion. See ref.doc
  1668. under ASSEM..END ASSEM for details.
  1669.  
  1670.  
  1671. $$External references
  1672. -------------------
  1673. Reference can be made to a variable or function in another file which is
  1674. resolved at link time. You may for instance, have written a function in C
  1675. or assembler. It is possible to pass parameters to, call and obtain return
  1676. values (as with ACE SUBs) from such a function in ACE after declaring an 
  1677. external reference to the function with the EXTERNAL FUNCTION or DECLARE
  1678. FUNCTION ... EXTERNAL directive (see command and function reference for 
  1679. syntax).
  1680.  
  1681. When passing parameters, standard C parameter passing conventions
  1682. are used. Although some C compilers seem to pass all parameters as
  1683. 4 bytes per parameter on the stack, ACE allows 2 (short words) or 4 
  1684. byte parameters. Be aware of this! See prgs/ExternFunc for examples.
  1685.  
  1686. External variables can be assigned values like normal variables, eg:
  1687.  
  1688.         external RangeSeed&
  1689.         RangeSeed=5276&
  1690.  
  1691. Instead of the "&" qualifier, the following is also legal:
  1692.  
  1693.         external longint RangeSeed
  1694.  
  1695. External function return values may be of any type as may external variables.
  1696.  
  1697. Note however that externally referenced string variables are assumed to be 
  1698. arrays of characters ala C, eg.
  1699.  
  1700.         char my_buffer[80];
  1701. or
  1702.         char my_string[] = "Hello World!";
  1703.  
  1704. but _not_ a character pointer, eg:
  1705.  
  1706.         char *a_char_pointer = "Hello World!";
  1707.             
  1708. Use a C function to return a character pointer, and externally reference it
  1709. from your ACE program.
  1710.  
  1711. All external reference identifiers have an underscore prefixed by ACE but
  1712. this is optional when declaring or using an external reference. C compilers 
  1713. always seem to prefix referenceable symbols with an underscore, so ACE does 
  1714. too.
  1715.  
  1716. Note that the names of external references (all except external SUBs -
  1717. see below) *are* case sensitive.
  1718.  
  1719. Also, the bas script can take as a third argument the name of the object 
  1720. file produced from the original C or assembly source (ie: .o or .lib file) 
  1721. which contains the external function or variable to be linked with your
  1722. ACE program. AIDE has facilities which allow for the linking of multiple
  1723. object modules.
  1724.  
  1725. You can't easily call ACE SUBs from C or assembler because ACE SUBs don't 
  1726. use C parameter passing conventions and ACE code relies heavily upon linking
  1727. code from run-time libraries (db.lib and startup.lib).
  1728.  
  1729.  
  1730. $$Common and Global variables
  1731. ---------------------------
  1732. It is sometimes desirable for variables to be static (in the BSS segment) rather
  1733. than stack-allocated. For example, since in a SUBmod (see next section), there is
  1734. no main-program level, only the environment of individual subprograms, there can 
  1735. be no stack-allocated main-program variables. An ACE Global variable solves
  1736. this problem by permitting the creation of simple, static variables at level 0
  1737. (main-program level).
  1738.  
  1739. A Global variable's scope is the _whole_ source module from the point of 
  1740. declaration. A Common variable is the same except that it is exported to any
  1741. other module that wishes to use it. So, for example, one ACE module may contain:
  1742.  
  1743.     Common Single x
  1744.  
  1745. while another has the declaration:
  1746.  
  1747.     External Single x
  1748.  
  1749. which is a reference to the former. The scope of a Common is the same as that
  1750. for a global, except that its fame can spread far and wide to other modules.
  1751. Due to this scoping, there is no need to explicitly share Commons or Globals
  1752. in SUBs.
  1753.  
  1754. In short, Common and Global variables have similar semantics to Externals
  1755. with the exception that a Common or Global string variable may not be of
  1756. the form:
  1757.  
  1758.     Common | Global String <id> Address <addr>
  1759.  
  1760. but the Size option may still be used.
  1761.  
  1762.  
  1763. $$Subprogram modules (SUBmods)
  1764. ----------------------------
  1765. It is possible to create libraries of ACE subprograms and so to have
  1766. multi-file ACE projects. For example in one file you can have:
  1767.  
  1768.     SUB lines(n) EXTERNAL
  1769.       FOR i=1 to n
  1770.         LINE (RND*640,RND*200)-(RND*640,RND*200)
  1771.       NEXT
  1772.     END SUB
  1773.  
  1774. and in another file:
  1775.  
  1776.     '..main
  1777.     DECLARE SUB lines(n) EXTERNAL
  1778.     LIBRARY "graphics.library"
  1779.     WINDOW 1,,(0,0)-(640,200)
  1780.     lines(500)
  1781.     WINDOW CLOSE 1
  1782.     END
  1783.  
  1784. If the latter file is called say, main.b and the former is called lines.b
  1785. then the following sequence of shell commands will give you an executable
  1786. called main:
  1787.  
  1788.     ace -Om lines        { The -m switch is the key here }
  1789.     a68k lines.s
  1790.     bas -O main lines.o
  1791.  
  1792. The first two commands can be replaced by:
  1793.  
  1794.     module lines
  1795.  
  1796. which is a shell script in the bin directory. The effect of the last of 
  1797. the 3 commands shown above can also be achieved via the Linker menu in 
  1798. AIDE, while the Compiler menu "Create Linkable Module" option is the 
  1799. equivalent of the first two.
  1800.  
  1801. There are a few things to be kept in mind when using ACE modules:
  1802.     
  1803.     1. Only subprograms - not subroutines (ie. via GOTO/GOSUB) - in 
  1804.     such modules can be called from other modules.
  1805.  
  1806.     2. The main module *MUST* open all standard libraries required
  1807.     by the other ACE modules linked to it. If in doubt add the 
  1808.     following lines of code at the top of your main program:
  1809.  
  1810.             LIBRARY mathffp
  1811.             LIBRARY mathtrans
  1812.             LIBRARY graphics
  1813.             LIBRARY intuition
  1814.             LIBRARY translator    '..only if TRANSLATE$ used
  1815.  
  1816.     If your code works as a single-module program but you invoke 
  1817.     the GURU or your program just doesn't work anymore when part 
  1818.     of it is placed into a linkable module, the above should fix it.
  1819.  
  1820.     3. The "m" switch creates an assembly source module containing 
  1821.     bare code with no calls to the startup functions normally invoked
  1822.     by an ACE program. Because of this, you need to keep the following
  1823.     in mind:
  1824.  
  1825.     - Command-line arguments must either be handled in the main
  1826.       program module or ARGCOUNT or ARG$ must be used one or more 
  1827.       times in the main module if they are going to be used in a 
  1828.       module produced with ACE's "m" switch. A line of code in 
  1829.       the main module such as:
  1830.  
  1831.         n = ARGCOUNT
  1832.  
  1833.       will suffice.
  1834.  
  1835.     - Likewise, if ALLOC is used in a module, it must also be used 
  1836.       at least once in the main program (eg. x=ALLOC(0) - no bytes
  1837.       will be allocated).     
  1838.  
  1839. In both cases, it is a matter of letting the compiler know that these
  1840. features are required by the final executable program which the above
  1841. actions will do.
  1842.  
  1843.     - In order to use DATA/READ within a module, make sure you issue
  1844.       a RESTORE command (in a subprogram) before the _first_ READ is 
  1845.       executed. This RESTORE command *must* be in a subprogram.
  1846.  
  1847.       For example, in the calling module:
  1848.  
  1849.         library mathffp
  1850.         declare sub data_test external
  1851.         data_test
  1852.  
  1853.       and in the library module:
  1854.  
  1855.         sub data_test external
  1856.             restore
  1857.             read x
  1858.             print x
  1859.             data 1.345    '..DATA lines _can_ be outside of SUBs
  1860.         end sub
  1861.  
  1862.     - ON TIMER normally has special startup code associated with it.
  1863.       Since there _is_ no startup code in modules, you will have to
  1864.       include the following lines of code such that they will be 
  1865.       executed before the ON TIMER code:
  1866.  
  1867.         external function ontimerstart
  1868.         ontimerstart
  1869.  
  1870.       For example, in the calling module:
  1871.  
  1872.           library mathffp
  1873.           declare sub timer_test external
  1874.           timer_test
  1875.  
  1876.       and in the library module:
  1877.  
  1878.           sub timer_test external
  1879.         SHORTINT count
  1880.           external function ontimerstart    '..can be outside SUB
  1881.           ontimerstart
  1882.             on timer(1) gosub do_beep
  1883.             timer on
  1884.             while -1
  1885.                 if count=5 then exit sub
  1886.             wend  
  1887.           do_beep:
  1888.               ++count
  1889.               beep
  1890.               return
  1891.         end sub
  1892.  
  1893. In addition, while subprograms can be treated as functions when in modules,
  1894. because there is no startup code, SUBs in a module are allocated no space
  1895. for return value storage. This means that function return values must be
  1896. passed by some method other than via the stack frame. In this case, ACE
  1897. uses the 680x0 register d0. Since d0 can be overwritten at any time, the
  1898. final thing a subprogram (in a module) should do is to assign the return 
  1899. value for the subprogram. C forces you to do this anyway, it's just 
  1900. that ACE normally gives you more flexibility than C. For example, the 
  1901. following:
  1902.  
  1903.     SUB even(n) EXTERNAL
  1904.       m = n MOD 2
  1905.       IF m=0 THEN
  1906.         even = -1
  1907.       ELSE
  1908.         even = 0
  1909.       END IF 
  1910.     END SUB
  1911.  
  1912. is acceptable since the final action of the subprogram is to assign itself
  1913. a return value. On the other hand, the following will cause d0 to be 
  1914. overwritten before the subprogram can return its value to the caller:
  1915.  
  1916.     SUB even(n) EXTERNAL
  1917.       m = n MOD 2
  1918.       IF m=0 THEN
  1919.         even = -1
  1920.       ELSE
  1921.         even = 0
  1922.       END IF 
  1923.         PRINT n;"mod 2 is";m    ' trashes d0!!
  1924.     END SUB
  1925.  
  1926. If need be of course, you can simply use a temporary local variable to
  1927. hold the final return value to be assigned later.
  1928.  
  1929. Note that the d0 convention ONLY applies when the "m" compiler switch is
  1930. used and that it applies to all subprograms in a module. However, even if
  1931. a SUB is declared to be external, the d0 parameter passing convention will
  1932. not be used unless either: (i) the "m" switch is used for the module in 
  1933. which the SUB is defined, or (ii) a SUB is used after being externally
  1934. referenced via DECLARE SUB ... EXTERNAL.
  1935.  
  1936. Instead of an external SUB, it is legal to have an external DEF FN. The
  1937. forward declaration is still the same as for a SUB. The definition for
  1938. the "even" function (in a module) looks like this:
  1939.  
  1940.     DEF even(n) EXTERNAL = -(n MOD 2)
  1941.  
  1942. Remember also that only variables which are local to SUBs and subprogram 
  1943. parameters may be used in a module. Global variables are not provided for 
  1944. correctly when declared in a module produced with the "m" switch, again 
  1945. because of the lack of startup code.
  1946.  
  1947. Finally, be careful to match up the return and parameter types for an 
  1948. externally defined subprogram and its forward (external) declaration.
  1949.  
  1950.  
  1951. $$Windows
  1952. -------
  1953. You can open up to 16 user-defined windows per program. See the command 
  1954. and function reference for the syntax of the WINDOW statement.
  1955.  
  1956. All user-defined windows are now (as of ACE v2.0) Intuition windows with 
  1957. each characteristic being configurable via the "type" parameter as per 
  1958. AmigaBASIC (see ref.doc).
  1959.  
  1960. Windows can be opened on the Workbench screen or on a user-defined screen.
  1961.  
  1962. The zeroth window (the shell/CLI, if the program was CLI launched) is now
  1963. the only instance of a DOS console window in ACE.
  1964.  
  1965. The WINDOW function takes a single parameter and returns information about
  1966. the current output window. See ref.doc for details.
  1967.  
  1968. Note that for user-defined windows, close-gadget clicks must be handled by 
  1969. the use of ON WINDOW event trapping or via the "w" compiler switch (or the
  1970. OPTION w+ command).
  1971.  
  1972. Please read the next section for more information about how windows relate
  1973. to screens in ACE.
  1974.  
  1975.   
  1976. $$Screens
  1977. -------
  1978. A single program can have open nine screens at once (memory permitting).
  1979.  
  1980. By default, when a screen is opened, a (BORDERLESS+BACKDROP) window
  1981. the same size as the screen is also opened. Subsequent output is directed 
  1982. to and input received from this window until the screen is closed (unless 
  1983. other windows are defined for the screen). Note that this feature is not 
  1984. found in AmigaBASIC. Note also that this default window is *not* counted
  1985. as having a window-id of 0. That privilege is reserved for the shell window
  1986. if the program was shell-launched. Read on...
  1987.  
  1988. The main use for such a default window is to provide a simple graphics
  1989. output "slate" for quick-and-dirty programs. The borderless+backdrop
  1990. characteristic prevents user-defined windows which may later be opened 
  1991. onto the screen from accidentally being depth arranged behind an invisible
  1992. window where they would stay for the remainder of that screen's life. With
  1993. a backdrop window this cannot happen since it will _always_ be the rear-most
  1994. window for a screen.
  1995.  
  1996. Text and graphics positions will be different on a screen's default window 
  1997. than for user-defined windows. For example, text in the first row will be 
  1998. partially off the top of the screen, so LOCATE may need to be used to adjust 
  1999. this. In short, I recommend that default windows now ONLY be used for rough 
  2000. output. If you still want a borderless window, use the  WINDOW command and 
  2001. ensure that the window-type has 32 as a component.
  2002.  
  2003. Avoid mixing the use of default and user-defined windows. Except for the
  2004. simple case in which you use nothing but screens and their default windows
  2005. you should consider your own windows to be the primary output destination 
  2006. for graphics and text.
  2007.  
  2008. Windows with depth gadgets cannot be sent behind the default window, but 
  2009. one screen can be sent to the back of other screens. It can also be moved 
  2010. vertically (and possibly horizontally). SCREEN BACK|FORWARD can be used to 
  2011. shuffle screens under program control.
  2012.  
  2013. When a screen is closed, ACE makes the screen with the next highest id 
  2014. the current one, so it is advisable to open and close screens in ascending 
  2015. and descending order.
  2016.  
  2017. A special SCREEN function exists in ACE which returns pointers to various
  2018. Intuition structures (window,screen,rastport,viewport,bitmap) and x,y font
  2019. sizes. This is detailed in the command and function reference (ref.doc) as 
  2020. are the following commands: SCREEN, SCREEN CLOSE, PALETTE and PRINTS. The 
  2021. latter is now redundant since all commands and functions can - as of ACE v2.0 
  2022. - be used transparently for screens, user-defined windows and the shell/CLI.
  2023.  
  2024.  
  2025. $$Gadgets
  2026. -------
  2027. ACE supports the Amiga's three standard gadget types: boolean, proportional 
  2028. (vertical and horizontal), and string (including long integer). 
  2029.  
  2030. Since one of my aims is to support all Amigas running everything from Wb 1.3 
  2031. to Wb 3.0, I have chosen to stick with simple Intuition gadgets for now.
  2032.  
  2033. Even so, ACE now supports the 3D bevel-box look of GadTools gadgets found
  2034. under Wb 2.x/3.0. Moreover, a BEVELBOX command allows the programmer to
  2035. create such boxes at will.
  2036.  
  2037. A future revision may support other gadget types, such as radio buttons, 
  2038. check boxes, list boxes etc.
  2039.  
  2040. Memory permitting, up to 255 gadgets can be created during a single program 
  2041. run.
  2042.  
  2043. The GADGET command creates a gadget with specific features while GADGET CLOSE 
  2044. removes the gadget from the window. Once created, a gadget can be enabled or
  2045. disabled, indeed it can be disabled upon creation if so desired. The GADGET
  2046. MOD command modifies the state of a slider (knob size and position).
  2047.  
  2048. Having created a gadget or gadgets, you must then decide how to receive and
  2049. handle information from them. ACE provides four methods: standard event
  2050. trapping (ON GADGET), polling (via the GADGET function), WAITing for a
  2051. specific gadget or WAITing for any gadget.
  2052.  
  2053. Where it is possible to make your programs modal (ie. focussed upon a single
  2054. event or event type) you can use the GADGET WAIT command.
  2055.  
  2056. The following commands set up a window with two boolean gadgets and a close 
  2057. gadget. The latter is set up by Intuition with the WINDOW command.
  2058.  
  2059. The program traps WINDOW and GADGET events. The comments should help you to
  2060. understand the code.
  2061.  
  2062. CONST having_fun = -1&
  2063.  
  2064. WINDOW 1,"Gadgets",(0,0)-(640,200),8
  2065.  
  2066. GADGET 1,ON,"Hit Me",(3,3)-(75,20),BUTTON,1
  2067. GADGET 2,OFF,"Quit",(100,150)-(200,175),BUTTON,2
  2068.  
  2069. ON GADGET GOSUB gadget_handler
  2070. GADGET ON
  2071.  
  2072. ON WINDOW GOTO quit
  2073. WINDOW ON
  2074.  
  2075. '..main loop (actually does nothing, but is necessary for event trapping)
  2076. WHILE having_fun
  2077.   '..have a nap while nothing's happening 
  2078.   '..(don't hog the machine by busy waiting) 
  2079.   SLEEP        
  2080. WEND
  2081.  
  2082. gadget_handler:
  2083.   '..find out which gadget was selected
  2084.   gad = GADGET(1)
  2085.   LOCATE 12,40:PRINT "<<";gad;">>" 
  2086.   if gad = 2 then quit    
  2087. RETURN
  2088.  
  2089. quit:
  2090.   GADGET CLOSE 2
  2091.   GADGET CLOSE 1
  2092.  
  2093.   WINDOW CLOSE 1
  2094. END
  2095.  
  2096. Alternatively, you could poll for a gadget to the exclusion of other events:
  2097.  
  2098. .
  2099. .
  2100. '..await a gadget selection
  2101. REPEAT
  2102.   WHILE NOT GADGET(0)
  2103.     SLEEP  '..be a little nice to other tasks
  2104.   WEND
  2105.   
  2106.   '..which one?
  2107.   gad = GADGET(1)
  2108.   LOCATE 12,40
  2109.   PRINT "<<";gad;">>" 
  2110. UNTIL gad=2
  2111. .
  2112. .
  2113.  
  2114. Finally, you can wait for a gadget:
  2115.  
  2116. .
  2117. .
  2118. GADGET WAIT 2      '.."GADGET WAIT 0" waits for ANY gadget! -> BEST method!
  2119. .
  2120. .
  2121.  
  2122. See the program prgs/GUI/ACEgadgets.b for an example of gadget programming
  2123. in ACE.
  2124.  
  2125. For boolean gadgets you can - if you need to - get information about the 
  2126. width and height of the gadget's text font by calling SCREEN(5) and 
  2127. SCREEN(6). If you need more precise width information, use the graphics 
  2128. library TextLength or TextExtent (v36) function.
  2129.  
  2130. String and LongInt gadgets now have associated with them a 1K buffer.
  2131.  
  2132. For more details about the GADGET commands and function, see ref.doc.
  2133.  
  2134.  
  2135. $$Menus
  2136. -----
  2137. ACE supports menus ala AmigaBASIC, with two additions: menu item keyboard
  2138. equivalents and a MENU WAIT command. The latter puts the program to sleep 
  2139. until a menu event occurs. The former is specified by an optional parameter 
  2140. to the MENU command, for example:
  2141.  
  2142.     MENU 1,5,1,"Quit","Q"
  2143.  
  2144. defines menu item number 5 in menu number 1 to be the 'Quit' option and 
  2145. sets up a command-key sequence (Amiga-Q) for that item. The third parameter
  2146. enables the menu item as per AmigaBASIC.
  2147.  
  2148. Note that although ACE adjusts menu text for font size and type as set
  2149. via preferences, some fonts may require you to pad your menu title/item 
  2150. names with blanks when using command keys to avoid overlaps, so it is a
  2151. good idea to add a couple of spaces to the end of a menu item string.
  2152.  
  2153. For an example of menu programming with ACE see prgs/ifs.b. For a better
  2154. example, see the source code for AIDE. Over time I will modify some of 
  2155. the other example programs in the archive so that they are menu-driven.
  2156.  
  2157. Note that in ACE, MENU CLEAR replaces MENU RESET.
  2158.  
  2159. See ref.doc for more details about the MENU commands and function. See
  2160. also the SUBmod/Menu directory for a SUBmod which permits the creation
  2161. of GadTools (OS Release 2.x/3.x) menus including submenus while still
  2162. allowing the MENU(n) function to be used. In fact, MENU(2) returns the
  2163. submenu item selected.
  2164.  
  2165.  
  2166. $$Requesters
  2167. ----------
  2168. As of version 2.0, ACE supports 3 standard requesters:
  2169.  
  2170.     - System requester
  2171.     - File requester
  2172.     - Input requesters (STRING and LONGINT)
  2173.  
  2174. Visual Basic for Windows has had an influence upon me and led me to add these
  2175. to ACE since I have now come to expect them. You can get the most commonly 
  2176. needed requesters with a single line of ACE code!
  2177.  
  2178. If you are running Wb 2.x and above, ACE generates an ASL file requester.
  2179.  
  2180. For Wb 1.3 an ARP file requester is invoked for two simple reasons:
  2181.  
  2182.     - It is quite acceptable.
  2183.     - The arp.library is common on Wb 1.3 systems.
  2184.  
  2185. See MSGBOX, FILEBOX, INPUTBOX and INPUTBOX$ in ref.doc for more. The
  2186. SUBmods directory contains other requesters to enhance your programs,
  2187. eg. FontReq, EasyRequest.
  2188.  
  2189.     
  2190. $$Turtle Graphics
  2191. ---------------
  2192. You may be wondering one or more of the following:
  2193.  
  2194.     - what the heck is Turtle Graphics?
  2195.     - isn't that for kids?
  2196.     - why did he include THAT?
  2197.  
  2198. To answer the first question: Turtle Graphics (TG) originated as a subset of 
  2199. the language LOGO invented by Seymour Papert et al at MIT. LOGO was originally 
  2200. intended as a language for learning. Children are able to write simple programs
  2201. to draw shapes on the computer's screen or move a Turtle - a dome-shaped robot 
  2202. - on a sheet of paper on the floor, learning about geometry "by doing" and
  2203. having fun to boot. 
  2204.  
  2205. LOGO also has many Lisp-like qualities and so can be used as a language for 
  2206. AI work, although to my knowledge, it's not.
  2207.  
  2208. But I digress. Apart from the fun kids can have with TG, it's actually 
  2209. possible to construct quite complex shapes with it. Combined with recursion,
  2210. TG is a powerful tool. It is particularly useful in plotting many fractal
  2211. shapes (see snowflake.b, dragon.b).
  2212.  
  2213. Since the first LOGO, there have been many manifestations of TG. Turbo Pascal 
  2214. for the PC and the Mac have both had TG.
  2215.  
  2216. A few years ago, I  wrote a pure TG subset of LOGO which used the same syntax 
  2217. as the original language and allowed recursive procedures. I've also written 
  2218. TG functions in C. Both of these have been useful to me and I've often wished 
  2219. that BASIC came with TG built-in. Well, now one dialect does!
  2220.  
  2221. For some examples of the use of Turtle Graphics in ACE, see the following
  2222. programs:
  2223.  
  2224.     - tree.b
  2225.     - flower.b
  2226.     - boxit.b
  2227.     - torus.b
  2228.     - dragon.b
  2229.     - snowflake.b
  2230.     - bst.b
  2231.  
  2232. The above discussion should have answered the second question. As for 
  2233. the third, the answer is: because I wanted to!! :^)
  2234.  
  2235. Okay, enough philosophy. Here's the ACE stuff:
  2236.  
  2237. BACK n        - move turtle back by n.
  2238. FORWARD n    - move turtle forward by n.
  2239. HEADING     - return turtle's current heading in degrees (0..359).
  2240. HOME        - move turtle back to its home position.
  2241. PENDOWN        - put turtle's pen down. 
  2242. PENUP        - lift turtle's pen up.
  2243. SETHEADING degs - change turtle's heading to degs.
  2244. SETXY x,y    - change turtle's current x,y location.
  2245. TURN degs    - rotate turtle by degs.
  2246. TURNLEFT degs    - turn turtle left by degs.
  2247. TURNRIGHT degs  - turn turtle right by degs.
  2248. XCOR        - return turtle's current x-coordinate.
  2249. YCOR        - return turtle's current y-coordinate.
  2250.  
  2251. where:
  2252.     - n is pixels
  2253.     - degs is a signed short integer representing degrees with
  2254.       the turtle starting at a 270 degree orientation -- pointing up.
  2255.     - home is the turtle's x,y start location (0,0).
  2256.  
  2257. Note that the X:Y ratio can be modified thus:
  2258.  
  2259.     EXTERNAL SINGLE tg_xy_ratio
  2260.     tg_xy_ratio = 1.125    
  2261.  
  2262. but this should not be necessary (from v2.19) since ACE determines the
  2263. correct aspect ratio for each user-defined screen when it is opened. A 
  2264. hi-res, non-interlaced Workbench screen is assumed at startup however. 
  2265. The correct values for tg_xy_ratio are shown below:
  2266.  
  2267.     Screen mode            Aspect ratio    
  2268.     -----------            ------------
  2269.     Lo-res, non-interlaced        0.9375
  2270.     Hi-res, non-interlaced        1.875
  2271.     Lo-res, interlaced        0.46875
  2272.     Hi-res, interlaced        0.9375
  2273.     Hold and Modify (HAM)        0.9375
  2274.     Extra-Halfbrite            0.9375
  2275.  
  2276. Most LOGO environments use a coordinate system where 0,0 is at the center of
  2277. the screen and positions to the left and down of this origin are negative 
  2278. while those up and to the right are positive. ACE's TG system however, uses 
  2279. the Amiga's normal graphics coordinate system with 0,0 at the top left of 
  2280. the screen/window so as to maintain consistency with ACE's normal graphics 
  2281. commands and functions (eg: POINT, PSET, LINE, PAINT, CIRCLE, AREAFILL).
  2282.   
  2283. If a negative value is specified for the turnleft or turnright commands,
  2284. the turtle will be rotated in the opposite direction to that indicated by
  2285. the the command name. Note that there is also a TURN command.
  2286.  
  2287. When using ACE's TG system, it's best to think of an imaginary turtle (in LOGO
  2288. it's usually a small triangle on the screen) which rotates and moves according
  2289. to your whim. The turtle can either have its pen lowered or raised - and will
  2290. therefore draw or not - which is useful when you need to move in a relative 
  2291. fashion from one location to another without drawing anything.      
  2292.  
  2293. SetXY is like the graphics library Move() command and may need to be preceded 
  2294. by PENUP unless you want to draw a line as the turtle finds its new position.
  2295.  
  2296. To change the colour of the drawing pen, use the COLOR command.
  2297.  
  2298. That's probably enough about ACE's Turtle Graphics. Oh by the way, if you want
  2299. to know more about the origins and uses of Logo, read Papert's "Mindstorms"
  2300. and his recent book entitled "The Children's Machine: Rethinking School in the 
  2301. Age of the Computer". They make for interesting reading.
  2302.  
  2303. The archetypal book on TG however, is "Turtle Geometry" by Abelson and diSessa.
  2304.  
  2305. On a related note, I wrote a paper called "Turtle Graphics and J" which
  2306. appeared in the British APL Association's journal, Vector, Vol.12 No.3,
  2307. January 1996. J is a cool language of the functional variety and a modern
  2308. dialect of APL. These two are often unkindly referred to as read-only 
  2309. languages, although not entirely without justification. Here's an example
  2310. of J code:
  2311.  
  2312.     +/ % >: i.100
  2313.  
  2314. which says: "sum the reciprocals of the integers 1..100". Neat eh? The 
  2315. equivalent ACE code would be:
  2316.  
  2317.     Single i,sum
  2318.     For i=1 To 100
  2319.       sum = sum + 1/i
  2320.     Next i
  2321.  
  2322. Not nearly as pretty. :)
  2323.  
  2324. While I think of it, Sherry Turkle wrote a book called "The Second Self: 
  2325. Computers and the human spirit", which I recommend if you're at all 
  2326. interested in the psychological/social effects of computing.
  2327.  
  2328.  
  2329. $$Loading & displaying IFF pictures
  2330. ---------------------------------
  2331. IFF graphics files can now be loaded and displayed with ACE by using 
  2332. a few simple commands and functions.
  2333.  
  2334. The short example program prgs/gfx/iff.b demonstrates typical usage.
  2335.  
  2336. IFF READ uses the freeware ILBM.library but you don't need to have this
  2337. since it will be created by ACE automatically at run-time if need be. If
  2338. LIBS:ilbm.library is not found at run-time ACE will use the library's binary 
  2339. image - which is stored in db.lib - to create ram:ILBMtmp/ilbm.library. This
  2340. file and the directory ILBMtmp will be removed when the program exits. The
  2341. idea of using a binary image like this was Roland Acton's.
  2342.  
  2343. See ref.doc for details of the IFF commands and function.
  2344.  
  2345.  
  2346. $$Sound
  2347. -----
  2348. ACE provides you with similar functionality as AmigaBASIC for sound
  2349. generation. It also allows you to do some things that AmigaBASIC doesn't.
  2350.  
  2351. See prgs/sound/sound.b for an example of how to use ACE's sound facilities 
  2352. in general.
  2353.  
  2354. How many times have you wished that AmigaBASIC would let you produce
  2355. white noise easily like the good ol' C64 and Vic-20 did?
  2356.  
  2357. Well, you'll be pleased to know that ACE allows you to do this. All you 
  2358. have to do is allocate about 4000 or more bytes of Chip RAM (upwards of 
  2359. 4000 bytes yields better quality white noise), poke it with random values 
  2360. (between -128 and 127), call WAVE and you're set (see sound.b)!
  2361.  
  2362. Moreover, you can actually play sound samples (IFF or otherwise) in the
  2363. same way, using just the two commands WAVE and SOUND (see prgs/sound/play.b). 
  2364.  
  2365. As with AmigaBASIC, a sine waveform is the default, but through the WAVE
  2366. statement you can create any waveform you wish including sawtooth, triangle, 
  2367. square and random (white noise).
  2368.  
  2369. WAVE has the following syntaxes:
  2370.  
  2371.     WAVE voice,SIN
  2372. and    
  2373.     WAVE voice,waveform-address,byte-count
  2374.  
  2375. where waveform-address is the start of a block of memory where the waveform
  2376. resides (an area of ALLOC'd CHIP memory) and byte-count is the number of bytes 
  2377. in the waveform table.
  2378.  
  2379. The SOUND statement syntax is as follows:
  2380.  
  2381.     SOUND period,duration[,volume][,voice]
  2382.  
  2383. This is different to AmigaBASIC in a number of ways. First, in ACE you
  2384. specify the sampling period NOT the frequency. This was easier to implement
  2385. and still provides the same functionality, but if you want specific notes, 
  2386. you'll have to do the calculations yourself (see equations below).
  2387.  
  2388. Sampling period is inversely proportional to frequency, so a high sampling
  2389. rate corresponds to a low frequency and vice-versa. ACE allows you to
  2390. specify a sampling period in the range 124..32767.
  2391.  
  2392. The duration is a single-precision value as in AmigaBASIC but can range from 
  2393. 0..999 (instead of 0..77). This range is somewhat arbitrary, but gives plenty
  2394. of scope for large sound samples. This specifies the length of time that a 
  2395. tone should be played for. A duration of 18.2 corresponds to about 1 second. 
  2396.  
  2397. Volume defaults to 64 if not specified and can range from 0..64.
  2398.  
  2399. The voice can be in the range 0..3 - since there are 4 audio channels - 
  2400. with 0 & 3 corresponding to the left speaker and 1 & 2 to the right.
  2401. The default voice is 0.
  2402.  
  2403. At the moment, ACE's SOUND statement isn't very good when used to produce a 
  2404. series of short pulses, although this is somewhat dependent upon the waveform 
  2405. in use. In any case, more work needs to be done in this area to prevent 
  2406. "popping" between SOUND statements when the audio hardware is turned on and 
  2407. off in rapid sequence.
  2408.  
  2409. ACE sound is produced by programming the hardware directly. A future version
  2410. will utilise the audio device instead. Indeed, the SOUND statement in ACE 
  2411. may change in the future to be more in line with AmigaBASIC (see also "Future 
  2412. Versions").
  2413.  
  2414. Finally, here's some useful equations for use in conjunction with ACE's SOUND 
  2415. statement:
  2416.  
  2417.     samples/second to period:
  2418.     ------------------------
  2419.     period = 3579546 / samples-per-second
  2420.     
  2421.     musical note to period:
  2422.     ----------------------
  2423.     period = 3579546 / (length * frequency)
  2424.  
  2425.     where length is the size of the waveform table in bytes 
  2426.     (32 bytes for ACE's sine waveform) and frequency is the
  2427.     note itself (eg: middle C is 523.25 Hz).
  2428.  
  2429.     duration value for one waveform cycle:
  2430.     -------------------------------------
  2431.     duration = .279365 * period * length / 1E6 * 18.2
  2432.  
  2433.         
  2434. $$Event trapping
  2435. --------------
  2436. ACE provides for AmigaBASIC-style event trapping, with additions. The following 
  2437. event types are supported:
  2438.  
  2439.     BREAK     -  user break: ctrl-c.
  2440.     MOUSE     -  left mouse button press.
  2441.     TIMER(n)  -  cause a trap every n seconds.
  2442.     ERROR      -  I/O and other errors.
  2443.     MENU      -  menu selection.
  2444.     WINDOW      -  window event: close-gadget click. * 
  2445.     GADGET      -  user-defined gadget selection. *
  2446.  
  2447.     * Not supported by AmigaBASIC.
  2448.  
  2449. Event trapping in ACE works by checking for a given event at strategic points
  2450. in a program (before NEXT, WEND, GOTO, CALL, PRINT etc) and if an event is
  2451. detected, control is passed to a trap handling routine. Note that trapping here
  2452. does not refer to CPU traps (exceptions).
  2453.  
  2454. Even if your program expects to do nothing but trap events, you'll need a
  2455. loop like this:
  2456.  
  2457.     WHILE -1
  2458.       SLEEP      '..don't hog the CPU  [optional but nice] 
  2459.     WEND
  2460.  
  2461. if you wish to have any events handled by your program.
  2462.  
  2463. The specification for the trapping of an event can be via:
  2464.  
  2465.     ON <event> GOSUB | GOTO <label>|<line-number> (eg. ON BREAK GOTO quit)
  2466.     or
  2467.     ON <event> CALL <SUBname> (eg. ON BREAK CALL quit)
  2468.  
  2469. which indicates the routine/SUB to which control is to be passed when an event
  2470. is trapped. This is followed at some stage by:
  2471.  
  2472.     <event> ON  (eg. BREAK ON)  
  2473.  
  2474. which causes the compiled program from that point _until_ the trap handling 
  2475. routine, to contain hidden event trapping code.
  2476.  
  2477. Other commands are:
  2478.  
  2479.     <event> STOP
  2480.  
  2481. which disables trapping for the event until another <event> ON is issued, 
  2482. and:
  2483.  
  2484.     <event> OFF
  2485.  
  2486. which disables trapping for the event permanently.
  2487.  
  2488. Just so there is no misunderstanding, the latter two commands prevent the 
  2489. inclusion of event trapping code for a specific event in your program at the 
  2490. assembly source level. They do this from the point in an ACE program at 
  2491. which they are issued.
  2492.  
  2493. Here's a typical example:
  2494.  
  2495.     ON BREAK GOTO quit
  2496.     BREAK ON
  2497.  
  2498.     for i=1 to 1000000
  2499.      print i
  2500.     next
  2501.  
  2502.     quit:
  2503.       PRINT "**break!"
  2504.       STOP
  2505.  
  2506. In the case of subroutines, it is a good idea to put trap handlers at the end 
  2507. of a program, since once the handler for an event is found by the compiler, no 
  2508. more event trapping code is generated for that event even if there is code below 
  2509. the handing routine. In other words, the equivalent of an <event> OFF command is 
  2510. issued once the trap handling subroutine is found by the compiler.
  2511.  
  2512. If using a subprogram as an event handler, the SUB must either be defined or 
  2513. declared (using DECLARE SUB) before the appropriate ON <event> CALL <SUBname> 
  2514. statement. To avoid hidden recursive subprogram calls, a silent <event> OFF is 
  2515. issued when a SUB is found after an <event> ON directive, eg.
  2516.  
  2517.     DECLARE SUB foo
  2518.     .
  2519.     .
  2520.     ON BREAK CALL foo
  2521.     BREAK ON
  2522.     .
  2523.     .
  2524.     SUB foo
  2525.     .        <- ACE issues a silent BREAK OFF here
  2526.     .           since we don't want foo called recursively!
  2527.     END SUB
  2528.  
  2529. For a SUB to be an event handler, it must not have a parameter list. If it
  2530. does, ACE will generate a compile-time error. Also, if a return value is 
  2531. given to a SUB, it will be ignored.
  2532.  
  2533. Simultaneous trapping of several different events is possible and in general
  2534. works very well. The use of INKEY$ and ON BREAK together when a user-defined 
  2535. window is the current output window leads to some competition. You may simply 
  2536. need to hit ctrl-c a few times in this circumstance for a user break to be 
  2537. accepted.
  2538.  
  2539. If you wish to trap only one kind of event you should consider the use of 
  2540. WAITing (only for menus and gadgets currently - see MENU/GADGET WAIT).
  2541.  
  2542.  
  2543. $$Interprocess Communication
  2544. --------------------------
  2545. ACE provides a simple IPC mechanism centered around a set of MESSAGE
  2546. commands (see ref.doc for full details).
  2547.  
  2548. ACEports represent a blocking/non-blocking, named IPC mechanism.
  2549.  
  2550. Put another way, ACEports provide an synchronous/asynchronous, indirectly 
  2551. named message-passing mechanism (Bal & Grune, p 202-206).
  2552.  
  2553. The mechanism is based upon Exec message ports and provides a simple way
  2554. for concurrently running ACE programs to communicate across unique, safe
  2555. channels. Strings can be sent as messages to a particular message port,
  2556. the name of which must be known in advance.
  2557.  
  2558. Messages may be of any length (memory permitting) and are queued.
  2559.  
  2560. Probably the best way to find out how the MESSAGE commands are used
  2561. in ACE is to compile, run and study the programs in prgs/ACEports.
  2562.   
  2563. ARexx capabilities are also planned for ACE at some stage.
  2564.  
  2565.  
  2566. $$Error Handling
  2567. --------------
  2568. The compiler messages generated by ACE are often different to the ones in the
  2569. AmigaBASIC interpreter (and ACE doesn't beep at you with each error) but they
  2570. are usually fairly clear.
  2571.  
  2572. Syntactically incorrect programs can lead ACE to produce a bunch of spurious 
  2573. error messages. In such cases, it's best to ignore all but the first one or 
  2574. two, unless there are "clusters" of messages which are separated by periods 
  2575. of error-free compilation. In short, ACE makes no attempt to do error recovery
  2576. at compile-time.
  2577.  
  2578. If you leave out END IF, WEND, UNTIL, NEXT, END SUB, END STRUCT or END CASE, 
  2579. there will be a corresponding number of error messages at the end of the 
  2580. compile. If you leave off two WENDs, you'll get 2 "WHILE without WEND" error
  2581. messages.
  2582.  
  2583. ACE generally reports the first error in a line of code and ignores the rest 
  2584. of the "bad" line. A typical message consists of the line containing the error,
  2585. a carat ("^") marker, and the error message itself. More work still needs to 
  2586. be done on ACE's compile-time error handling, but it's bearable.
  2587.  
  2588. No error messages are issued by ACE programs at run-time. Generally, when a 
  2589. program runs into something it can't do, or an erroneous request - like
  2590. trying to open two files to the same file number or trying to open a library 
  2591. that doesn't exist - the program will either quit or just not have the desired 
  2592. effect. 
  2593.  
  2594. Note that while the ERR function and ON ERROR event trapping are supported,
  2595. only file I/O, serial I/O, IFF, IPC (MESSAGE) and window/screen open errors 
  2596. are currently reported via these mechanisms. See ref.doc for details.
  2597.  
  2598.  
  2599. $$Notes for assembly programmers
  2600. ------------------------------
  2601. I've tried to make the assembly source files that ACE produces as 
  2602. readable as possible by using meaningful data object names. See also
  2603. "Compiler options" re: the compiler's "-c" switch.
  2604.  
  2605. Linked library routines use data registers d0-d6 and address registers 
  2606. a0-a3, while d7 is used for array index calculations. Also, a4 and a5 are 
  2607. used as stack frame pointers for variables and parameters.
  2608.  
  2609. Most db.lib routines don't save and restore registers via the stack, but 
  2610. the use of registers is internally consistent (ie: all registers are up for 
  2611. grabs but interdependent routines are written in such a way so as not to 
  2612. conflict). External function calls in ACE programs now _do_ save and restore 
  2613. registers.
  2614.  
  2615. The use of linked libraries means that the size of all executables is
  2616. fairly large. But given that disk space and memory are cheap, I'd rather
  2617. this than the alternative of having every executable be dependent upon one
  2618. or more special shared libraries at run-time. However, I will try to reduce
  2619. the size of executables. Some improvement has been made with the current
  2620. revision. Kendall Sears has suggested the creation of smaller versions of 
  2621. db.lib and startup.lib for use with shell-based programs. I like this idea
  2622. and will hopefully implement it when I have time.
  2623.  
  2624. Due to BASIC's tendency to coerce data types so much for the programmer,
  2625. the resulting code can look a little nasty, and big increases in efficiency 
  2626. can be gained by careful combinations of data types in expressions.
  2627.  
  2628. Writing ACE has so far been a learning experience for me and if when I started
  2629. I knew what I know now, I would have done many things differently.
  2630.  
  2631. My original rationale for passing parameters via registers to ACE (and shared) 
  2632. library functions was to improve execution speed. However, since I call lots 
  2633. of other functions (eg: in ami.lib) which require their parameters to be on 
  2634. the stack, I would probably call ALL functions in this way if I did it again. 
  2635.  
  2636. Moreover, my desire for internal consistency led me to a rather odd method of 
  2637. passing parameters to SUBs. This allowed me to treat parameters in the same way
  2638. as variables which is all very nice, but it led to other problems, chief among
  2639. them being the need to use a Forbid()/Permit() pair when sending parameters to 
  2640. a SUB. This works fine however, so I'm taking the view that if it 'aint broke,
  2641. I probably shouldn't fix it. 
  2642.  
  2643.  
  2644. $$Limitations
  2645. -----------
  2646. 1. Undeclared variables do NOT get a default zero or NULL value, so don't
  2647. assume ANYTHING about the contents of an uninitialised variable, eg.
  2648.  
  2649.     PRINT X 
  2650.  
  2651. will yield garbage if X has not been given a value. The optional variable 
  2652. declarations provided in ACE are therefore worth using since they DO give
  2653. variables an initial zero or NULL value.
  2654.  
  2655. 2. The precision of exponentiation begins to falter with large numbers (where 
  2656. the exponent is around 23 or higher) because all exponentiation is currently 
  2657. done in single-precision. Use either long integer multiplication or ACE's SHL 
  2658. function for greater accuracy, where integers are applicable. For example, 
  2659. compare SHL(2,22) with INT(2^23).
  2660.  
  2661. 3. See the LONGINT(n) function for getting around the problem of extracting a
  2662. large integer value from a string.
  2663.  
  2664. 4. While strings can be defined to be longer (or shorter) than 1K, there
  2665. are some ACE commands and functions which still assume a 1K limit, namely: 
  2666. STRING$, SPACE$, LINE INPUT#, INPUT and SWAP.
  2667.  
  2668. 5. Strings and arrays which are local to a subprogram will be overwritten if
  2669. the SUB has recursive calls to itself. The same applies to string parameters. 
  2670. In all these cases a single static data item is being referenced.
  2671.    
  2672. 6. If you issue RETURN from within a FOR loop, the return address will *not* 
  2673. be the top item on the stack. Instead, FOR..NEXT loop data will be. A GURU will 
  2674. almost certainly result. It is probably better to use a while or repeat loop 
  2675. if you must RETURN from within a loop. See also EXIT FOR in ref.doc which
  2676. allows for the safe, early termination of FOR loops, although it's not perfect.
  2677.  
  2678. 7. A shared variable cannot be used as a FOR loop index in ACE. Any attempt to
  2679. do so will result in a compile-time error.
  2680.  
  2681. 8. IF..THEN NEXT will not have the desired effect (it's bad coding anyway).
  2682. NEXT must always appear on a line by itself or as part of a multi-statement. 
  2683.  
  2684. 9. ACE does not consider "=>" to be the same symbol as ">=". In fact, ACE 
  2685. doesn't recognise the former at all. The same is true of "=<".
  2686.  
  2687. 10. The compiler only responds to ctrl-c during the main compilation phase, 
  2688. and not during optimisation or when target code is being written.
  2689.  
  2690. 11. Don't mix the compiler's "b"/"w" option with BREAK/WINDOW event trapping, 
  2691. as they will conflict.
  2692.  
  2693.  
  2694. $$Known Bugs
  2695. ---------- 
  2696. If mathieeesingtrans.library is not present at runtime, the FFP SPPow()
  2697. function will be used for exponentiation. This will produce incorrect
  2698. results for a combination of a negative base and odd exponent. Only pre-2.0
  2699. systems should be affected by this however. SPPow() is otherwise less
  2700. accurate and apparently slower than its IEEE counterpart, which is used if
  2701. the IEEE library is present.
  2702.  
  2703. The SAY(n) *function* works under release 2.x but not under 1.3. Since the 
  2704. function uses no 2.x-specific code, this is puzzling. The SAY command works 
  2705. under both 1.3 and 2.x however.
  2706.  
  2707. Some fonts cause the INPUTBOX[$] display (string gadget) to be corrupted. 
  2708. Stick to topaz for this where possible. A future revision may use a 
  2709. GadTools or BOOPSI requester (for 2.x/3.x machines).
  2710.  
  2711. A68K sometimes complains about string literal definitions produced by ACE 
  2712. if they are much longer than a single line.
  2713.   
  2714.  
  2715. $$Future versions
  2716. ---------------
  2717. Double-precision floating-point math is high on the agenda, as is some
  2718. kind of LIST datatype based upon Exec lists.
  2719.  
  2720. More graphics (eg: GET,PUT) commands and functions are planned and I also 
  2721. intend to fix any remaining differences between ACE and AmigaBASIC in this 
  2722. area. 
  2723.  
  2724. AGA screen modes will happen sometime.
  2725.  
  2726. I may provide support for sprites at some stage. 
  2727.  
  2728. Thus far, I've taken the approach of implementing what I most often use 
  2729. and what I have often wished for in a language.
  2730.  
  2731. In recent times I have been impressed by three things in the programming 
  2732. world: the rise of Object-Oriented Programming (OOP), Resources (as found
  2733. on the Macintosh and MS-Windows), Visual BASIC for Windows, and functional
  2734. languages such as J and Scheme.
  2735.  
  2736. The idea of resources (pioneered by the Macintosh resource fork and ResEdit) 
  2737. is a powerful one and Microsoft have picked up on this in Windows 3.x/95. 
  2738. I wish that Amiga executables had resources as standard, but alas, no.
  2739.  
  2740. I am trying to add more "visual" stuff to ACE, hence: gadgets, menus,
  2741. requesters, AIDE. You can expect to see more "visualising" of ACE as time
  2742. goes by. ReqEd, a GUI designer written in ACE, for ACE, is one example of 
  2743. this. To make ACE like Visual BASIC would take a major redesign, but I can 
  2744. at least try to take advantage of some of its features.
  2745.  
  2746.  
  2747. $$A note to PD libraries and reviewers
  2748. ------------------------------------
  2749. First, to those magazines who have reviewed ACE so far, let me say a big 
  2750. THANK YOU. Good publicity is always appreciated as is acknowledgement of 
  2751. the time I've spent on ACE.
  2752.    
  2753. I'd appreciate it if you would check with me (if possible) to ensure you
  2754. have the latest version of ACE before including it in your library or
  2755. reviewing it for a magazine. If you don't have e-mail access, I don't
  2756. expect you to do this (snail-mail is a pain isn't it!?).
  2757.  
  2758. Lastly, the wider ACE travels the happier I am, so I'm pleased to see
  2759. ACE turning up in the odd PD library. Please note however that I don't
  2760. wish people to profit financially from the distribution of ACE. You may
  2761. charge a fee which covers the cost of the disk and the copying thereof,
  2762. but no more.
  2763.  
  2764.  
  2765. $$Disclaimer
  2766. ----------
  2767. Although every care has been taken in the development and testing of the 
  2768. compiler and its libraries, the author will not be held liable for damages 
  2769. caused either directly or indirectly as a result of the use of ACE.
  2770.  
  2771.  
  2772. $$References
  2773. ----------
  2774. The following references have been used in developing ACE:
  2775.  
  2776. +----------------------------------------------------------------------------+
  2777. | "Amiga BASIC" (manual), 1985, Commodore-Amiga Inc. and Microsoft Inc.      |
  2778. |                                         |
  2779. | "Amiga ROM Kernel Reference Manual: Libraries", 1992, Commodore-Amiga         |
  2780. |                                         |
  2781. | "Amiga ROM Kernel Reference Manual: Devices", 1991, Commodore-Amiga         |
  2782. |                                         |
  2783. | Anderson & Thompson, 1990, "Mapping the Amiga", COMPUTE! Publications Inc. |
  2784. |                                         |
  2785. | Bal & Grune, 1994, "Programming Language Essentials", Addison-Wesley         |
  2786. |                                         |
  2787. | Bleek, Jenrich & Schulz, 1989, "Amiga C for Advanced Programmers", Abacus  |
  2788. |                                         |
  2789. | Choi, 1990, "Advanced Programming Techniques", University of Tasmania      |
  2790. |                                         |
  2791. | Dittrich, 1989, "Amiga Machine Language", Abacus                 |
  2792. +----------------------------------------------------------------------------+
  2793.  
  2794. This is by no means an exhaustive list, but it is representative.
  2795.  
  2796. Despite its not infrequent errors, "Mapping the Amiga" remains an excellent 
  2797. resource. I have also often referenced "Advanced Amiga C programming". 
  2798.  
  2799. Naturally, the two RKM volumes listed above and the "Amiga BASIC" manual are 
  2800. used regularly as well.
  2801.   
  2802. Although not listed, Commodore's Autodocs for the Amiga (supplied with the
  2803. Native Developer Kit) are also constantly used.
  2804.  
  2805. Young Choi's Advanced Programming notes in many ways provided the impetus
  2806. for the development of ACE. They were used in a compiler construction course
  2807. I took as an undergraduate. I thank Young for introducing me to the joys
  2808. of compiler writing, although I know he didn't intend me to spend *all* my
  2809. time writing programming language translators of one kind or another. :-)
  2810.  
  2811. Including the Pascal Minus compiler I wrote for that course, and the PC BASIC 
  2812. interpreter I wrote during the same period, I've since written a version of
  2813. Logo (turtle graphics subset), a Forth interpreter, and ACE, and other 
  2814. assorted compilers/interpreters.
  2815.  
  2816.  
  2817. $$Contacting the author
  2818. ---------------------
  2819.  
  2820. I am contactable via e-mail on: the Internet, Compuserve and Discovery 40/80.
  2821. Of course, there is also the telephone and snail-mail.
  2822.  
  2823. +-----------------------------------------------+
  2824. |     Internet:    ace@vision.net.au            |
  2825. |        D.Benn@appcomp.utas.edu.au     |
  2826. |                        |
  2827. |   Compuserve: 100033,605                  |
  2828. |                        |
  2829. |      Phone: (03) 6326 1461 [home]              |
  2830. |          (03) 6344 4432 [work]              |
  2831. |                              |
  2832. |    Address: 9 Mayne Street, Invermay,     |               
  2833. |          Tasmania, Australia, 7248              |
  2834. +-----------------------------------------------+
  2835.  
  2836.  
  2837. $$CyberspACE: FTP, mailing list, WWW
  2838. ----------------------------------
  2839. In February 1994 I was allowed to establish a listserver-based discussion 
  2840. list for ACE on one of the Unix boxes at my previous place of work, the 
  2841. University of Tasmania at Launceston's Department of Applied Computing 
  2842. and Mathematics.
  2843.  
  2844. The purpose of the list is to allow for the dissemination of information 
  2845. about ACE, the discussion of bugs, problems, solutions and ACE programming 
  2846. in general.
  2847.  
  2848. In September 1996, the ACE list moved to one of the BSDi Unix boxes at my
  2849. place of work, Vision Internet Services.
  2850.  
  2851. To subscribe to the list send (Internet) e-mail to:
  2852.  
  2853.     majordom@vision.net.au
  2854.  
  2855. The subject-line of the message is unimportant, but the first line of the 
  2856. message must be of the following format:
  2857.  
  2858.     subscribe acebasic
  2859.  
  2860. The listserver will send you a welcome message and information about how 
  2861. to use the list.
  2862.  
  2863. At about the same time as the ACE list was established, an anonymous FTP
  2864. server was set up at:
  2865.  
  2866.     ftp.appcomp.utas.edu.au
  2867.  
  2868. ACE-related files are stored in the directory:
  2869.  
  2870.     /pub/ACE
  2871.  
  2872. The ACE FTP site is also maintained at:
  2873.  
  2874.     ftp.vision.net.au
  2875. in:
  2876.     /pub/ACE
  2877.  
  2878. and should be considered to be the primary site now. There are lots of
  2879. extra goodies to be found on the FTP sites, including extra example
  2880. programs and more utilities.
  2881.  
  2882. There is also an ACE home page on the World Wide Web, the URL of which
  2883. is:
  2884.     http://www.vision.net.au/~ace/
  2885.  
  2886. A vote of thanks goes to my boss, Roy Austen for allowing me to use 
  2887. Vision Internet Services facilities for ACE activities.
  2888.  
  2889. I'd like to thank Tony Gray (Technical Services Manager) for maintaining 
  2890. the first listserver and Young Choi (Head of Department) for allowing me 
  2891. to use the department's facilities.
  2892.  
  2893. You should also check out dev/basic on Aminet sites, and the AmigaTech
  2894. forum on CompuServe for ACE related material.
  2895.   
  2896.  
  2897. $$Final word
  2898. ----------
  2899. Let me offer my thanks to Charlie Gibbs for his reliable assembler and to 
  2900. the Software Distillery for Blink. Without these excellent programs, far 
  2901. fewer Amiga compilers would have seen the light of day, including ACE. 
  2902.  
  2903. More recently, ACE users have also been able to make use of PhxAss and PhxLnk,
  2904. so Frank Willie and Volker Barthelmann deserve a round of applause too.
  2905.  
  2906. Sozobon C (ZC) has always been a reliable workhorse for me, so a vote of
  2907. thanks goes to Sozobon as well. Isn't freeware great?
  2908.  
  2909. I'd like to thank those people who have tested ACE so far. They are too 
  2910. numerous to mention here, but special thanks goes to Addison Laurent, 
  2911. Alan-Peyton Smith, Peter Zielinski, John Stiwinter and the members of
  2912. the ACE mailing list (see above).
  2913.  
  2914. These guys have given ACE a good workout on a variety of platforms ranging 
  2915. from an A1000 running Wb 1.3 to 68030 machines running Wb 3.0.
  2916.  
  2917. I'd especially like to thank Michael Zielinski for discovering a particularly 
  2918. serious bug which prevented branches of greater than 32K in length prior
  2919. to v1.02. Also, Enforcer hits reported by him started me on a trail which
  2920. led to a nasty string-related bug (see entry for 13/4/93 in docs/history).
  2921.  
  2922. Jarto 'Robin' Tarp pointed out how inefficient my first implementation
  2923. of INSTR was. It's considerably faster now (since v1.02).
  2924.  
  2925. Let me stress that any remaining bugs in ACE are entirely my fault.
  2926.  
  2927. Others have given me a great deal of encouragement and made useful comments 
  2928. The sense of community on the virtual world of the Net is a refreshing change 
  2929. from the general weirdness of the "real" world.
  2930.  
  2931. I'd like to thank John Stiwinter for all his excellent work in putting
  2932. together the AmigaGuide documents for ACE. Having ACE's reference material
  2933. in this format has enhanced its utility enormously. He has also done 
  2934. other stuff in the background for which I am grateful.
  2935.  
  2936. Of late, Nils Sjoholm has been doing a great deal of work for the ACE
  2937. project. He single-handledly converted all the C header files into a 
  2938. form which could be used by ACE not to mention writing numerous example
  2939. programs for shared libraries such as ReqTools and Triton.
  2940.  
  2941. This, in conjunction with Escom giving me permission to distribute the
  2942. bmaps has given a big boost to the project and makes ACE a serious 
  2943. system-level programming tool. I'd like to thank Dr Peter Kittel for 
  2944. giving me permission to make the bmaps available.
  2945.  
  2946. More recently still, Herbert Breuer has taken over work on AIDE, Daniel
  2947. Seifert has contributed NAP (New ACE Preprocessor), and Manuel Andre has
  2948. written a SuperOptimiser which makes ACE's -O switch pale by comparison.
  2949.  
  2950. Many of the subscribers to the ACE mailing list (see above section)
  2951. have given me plenty to think about, plenty of bug reports and plenty of 
  2952. support. In particular, thanks goes to Kendall Sears for keeping me on my 
  2953. toes and for providing expert technical knowledge of the Amiga's operating
  2954. system.
  2955.  
  2956. Jeff Harris, Chuck Kenney, Dan Oberlin, Sean Miller and Kenneth Brill,  
  2957. Bill Maddock, and John Mason have all contributed to ACE in their own ways. 
  2958. Thanks guys! Also, to all those who have e-mailed or written to me, thanks. 
  2959. You know who you are!
  2960.  
  2961. I'd also like to thank my wife Karen, for her encouragement and support, 
  2962. for putting up with the number of hours I spend at the computer, and
  2963. just for tolerating me generally. :-)  IFS is her favourite program so 
  2964. it's dedicated to her (try the "Green Fern").
  2965.  
  2966. Despite ACE's problems (see "Limitations" and "Known Bugs") it is proving
  2967. to be a useful tool for me, and if others can derive benefit from it, well, 
  2968. that's great. ACE is gradually coming to support the features I and others 
  2969. want it to, but there's still plenty of work to do.
  2970.  
  2971. The provision of support for shared library functions, external functions, 
  2972. machine code routines, inline assembly code, include files and SUBmods 
  2973. should go a long way towards making up for ACE's intrinsic shortcomings.
  2974.   
  2975. I hope you enjoy ACE and find it useful. I'm learning a great deal by 
  2976. developing it and having a lot of fun in the process. If you'd like to see
  2977. ACE developed further, feel free to send me a donation, but I certainly don't
  2978. expect you to do so. ACE development will continue, with or without such 
  2979. incentives. :)
  2980.  
  2981. What I DO want is feedback. If you have any problems, requests, queries or 
  2982. suggestions, I want to hear from you and I'd like to hear about interesting 
  2983. programs you've written with ACE. Send me the source code if you like. I'm
  2984. always on the lookout for good example programs to include in the ACE archive.
  2985.  
  2986. Remember that ACE is FreeWare, so redirect flames to NIL:  :^).
  2987.  
  2988. Happy programming!
  2989.  
  2990. Regards, David Benn
  2991. 12th September 1996
  2992.